/* ===== Tokens ===== */
:root {
  --bg: #fbfaf7;
  --bg-alt: #f2f0ea;
  --surface: #ffffff;
  --text: #1b1d22;
  --muted: #5d6270;
  --line: #e3e0d8;
  --accent: #0f7b6c;
  --accent-soft: #e2f3ef;
  --warn: #c2410c;
  --warn-soft: #fdecdf;
  --dark-bg: #12151b;
  --dark-surface: #1b2029;
  --dark-line: #2c3340;
  --dark-text: #e8eaef;
  --dark-muted: #9aa3b2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 32, .04), 0 8px 24px rgba(20, 24, 32, .06);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --bg-alt: #151a20;
    --surface: #1a1f27;
    --text: #e8eaef;
    --muted: #9aa3b2;
    --line: #2a313c;
    --accent: #3cc4ae;
    --accent-soft: #143530;
    --warn: #fb923c;
    --warn-soft: #3a2415;
    --dark-bg: #0a0c10;
    --dark-surface: #141922;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
  .skill__icons img[src*="amazonwebservices"],
  .cert img, .icon-aws { filter: invert(1) hue-rotate(180deg) brightness(1.2); }
  .skill__head img[src*="githubactions"] { filter: brightness(1.4); }
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 24px; }
@media screen and (max-width: 600px) { .wrap { padding-inline: 18px; } }

/* ===== Nav ===== */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav__inner {
  max-width: 1120px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.nav__logo { font-family: var(--mono); font-weight: 600; color: var(--text); text-decoration: none; }
.nav__logo span { color: var(--accent); }
.nav__links { display: flex; gap: 22px; overflow-x: auto; }
.nav__links a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap; }
.nav__links a:hover, .nav__links a.is-active { color: var(--text); }
@media screen and (max-width: 600px) {
  .nav__inner { padding: 10px 18px; }
  .nav__links { gap: 14px; }
  .nav__links a { font-size: 13px; }
  .nav__logo { display: none; }
}

/* ===== Buttons / tags ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 15px;
  transition: transform .15s ease, border-color .15s ease;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-1px); border-color: var(--text); }
.btn--primary { background: var(--text); color: var(--bg); border-color: var(--text); }

.tags, .chips { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  font-family: var(--mono); font-size: 12px; line-height: 1;
  padding: 6px 9px; border-radius: 6px; background: var(--bg-alt); color: var(--muted);
}
.chips li {
  font-size: 13px; line-height: 1; padding: 8px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}

/* ===== Hero ===== */
.hero { padding: 88px 0 56px; }
.hero__grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 56px; align-items: center; }
.eyebrow { font-family: var(--mono); font-size: 13px; color: var(--accent); letter-spacing: .06em; margin: 0 0 12px; }
.hero h1 { font-size: clamp(40px, 6vw, 64px); line-height: 1.1; margin: 0 0 24px; font-weight: 900; letter-spacing: .02em; }
.hero h1 small { display: block; font-size: .38em; font-weight: 500; color: var(--muted); letter-spacing: .08em; margin-top: 10px; }
.hero__lead { font-size: 17px; color: var(--muted); margin: 0 0 32px; max-width: 34em; }
.hero__lead strong { color: var(--text); }
.hero__cta { display: flex; flex-wrap: wrap; gap: 12px; }

.term {
  background: var(--dark-bg); color: var(--dark-text);
  border-radius: var(--radius); box-shadow: 0 20px 50px rgba(15, 20, 30, .22);
  overflow: hidden; border: 1px solid var(--dark-line);
}
.term__bar { display: flex; align-items: center; gap: 7px; padding: 12px 14px; background: var(--dark-surface); border-bottom: 1px solid var(--dark-line); }
.term__bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.term__bar i:nth-child(2) { background: #febc2e; }
.term__bar i:nth-child(3) { background: #28c840; }
.term__bar span { margin-left: 8px; font-family: var(--mono); font-size: 12px; color: var(--dark-muted); }
.term__body { margin: 0; padding: 20px 22px; font-family: var(--mono); font-size: 13.5px; line-height: 1.75; overflow-x: auto; }
.term .p { color: #3cc4ae; }
.term .k { color: #8ab4ff; }
.term .s { color: #f5c16c; }
.cursor { animation: blink 1s steps(1) infinite; color: #3cc4ae; }
@keyframes blink { 50% { opacity: 0; } }

.hero__stats {
  list-style: none; margin-top: 64px; margin-bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  padding-inline: 0; max-width: 1072px;
}
.hero__stats li { background: var(--surface); padding: 20px 22px; font-size: 13px; color: var(--muted); }
.hero__stats b { display: block; font-size: 28px; color: var(--text); line-height: 1.2; margin-bottom: 4px; font-weight: 900; }
.hero__stats b span { font-size: 14px; color: var(--muted); margin-left: 3px; font-weight: 500; }

@media screen and (max-width: 880px) {
  .hero { padding-top: 56px; }
  .hero__grid { grid-template-columns: 1fr; gap: 40px; }
  .hero__stats { grid-template-columns: repeat(2, 1fr); margin-inline: 24px; }
}
@media screen and (max-width: 600px) { .hero__stats { margin-inline: 18px; } }

/* ===== Sections ===== */
.section { padding: 96px 0; }
.section--alt { background: var(--bg-alt); }
.h2 { font-size: clamp(28px, 4vw, 40px); margin: 0 0 40px; font-weight: 900; display: flex; align-items: baseline; gap: 14px; letter-spacing: .01em; }
.h2 span { font-family: var(--mono); font-size: 14px; color: var(--accent); font-weight: 600; }
.section__lead { color: var(--muted); margin: -24px 0 40px; max-width: 40em; }
@media screen and (max-width: 600px) { .section { padding: 64px 0; } }

/* About */
.about { display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px; }
.about__body p { margin: 0 0 1.1em; }
.about__facts { margin: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; align-self: start; }
.about__facts div { background: var(--surface); padding: 14px 18px; }
.about__facts dt { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: .08em; text-transform: uppercase; }
.about__facts dd { margin: 2px 0 0; font-size: 14.5px; font-weight: 500; }
@media screen and (max-width: 880px) { .about { grid-template-columns: 1fr; gap: 28px; } }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
.tl { display: grid; grid-template-columns: 150px 1fr; gap: 24px; }
.tl__when { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 22px; line-height: 1.5; }
.tl__card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; box-shadow: var(--shadow); }
.tl__card h3 { margin: 0 0 8px; font-size: 19px; line-height: 1.5; }
.tl__card h3 em { display: inline-block; font-style: normal; font-size: 13px; font-weight: 500; color: var(--accent); margin-left: 6px; }
.tl__card p { margin: 0 0 .6em; font-size: 15px; color: var(--muted); }
@media screen and (max-width: 700px) {
  .tl { grid-template-columns: 1fr; gap: 6px; }
  .tl__when { padding-top: 0; }
  .tl__when br { display: none; }
  .tl__card { padding: 18px 20px; }
}

/* Skills */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.skill { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.skill p { margin: 12px 0 0; font-size: 14.5px; color: var(--muted); }
.skill--feature { grid-column: span 3; display: grid; grid-template-columns: 280px 1fr; column-gap: 32px; border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.skill--feature p { margin-top: 0; font-size: 15.5px; }
.skill--feature .chips { grid-column: 2; }
.skill--feature .skill__head { grid-row: span 2; }
.skill__head { display: flex; align-items: center; gap: 14px; }
.skill__head h3 { margin: 0; font-size: 18px; line-height: 1.3; }
.skill--feature .skill__head h3 { font-size: 26px; }
.skill__meta { margin: 2px 0 0 !important; font-size: 12.5px !important; font-family: var(--mono); color: var(--accent) !important; }
.skill__icons { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.skill__icons img { width: 32px; height: 32px; object-fit: contain; }
.skill__icons .icon-aws { width: 40px; }
@media screen and (max-width: 880px) {
  .skills { grid-template-columns: 1fr 1fr; }
  .skill--feature { grid-column: span 2; grid-template-columns: 1fr; }
  .skill--feature .chips { grid-column: 1; }
  .skill--feature .skill__head { grid-row: auto; margin-bottom: 12px; }
}
@media screen and (max-width: 600px) {
  .skills { grid-template-columns: 1fr; }
  .skill--feature { grid-column: span 1; }
}

.cert { margin-top: 24px; display: flex; align-items: center; gap: 20px; padding: 18px 24px; border-radius: var(--radius); background: var(--surface); border: 1px dashed var(--line); }
.cert img { width: 56px; height: auto; flex-shrink: 0; }
.cert p { margin: 0; }
.cert__label { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.cert__name { font-weight: 700; }
.cert__name span { font-family: var(--mono); font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 10px; }

/* ===== Infra (dark section) ===== */
.section--dark { background: var(--dark-bg); color: var(--dark-text); }
.section--dark .section__lead { color: var(--dark-muted); }
.section--dark .h2 span { color: #3cc4ae; }

.journey { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; counter-reset: s; }
.step { position: relative; background: var(--dark-surface); border: 1px solid var(--dark-line); border-radius: var(--radius); padding: 22px; }
.step::after { content: "→"; position: absolute; right: -14px; top: 38px; color: var(--dark-muted); font-size: 16px; }
.step:last-child::after { display: none; }
.step__icon { height: 44px; display: flex; align-items: center; margin-bottom: 14px; }
.step__icon img { max-height: 40px; width: auto; }
.step__icon img[src*="amazonwebservices"] { filter: invert(1) hue-rotate(180deg) brightness(1.3); }
.step__no { margin: 0; font-family: var(--mono); font-size: 11px; color: #3cc4ae; letter-spacing: .1em; }
.step h3 { margin: 4px 0 10px; font-size: 16.5px; line-height: 1.5; }
.step p { margin: 0; font-size: 14px; color: var(--dark-muted); line-height: 1.8; }
.step strong { color: var(--dark-text); }
.step--alert { border-color: #7a3a17; background: linear-gradient(180deg, #2a1c14, var(--dark-surface) 60%); }
.step--alert .step__no { color: #fb923c; }
@media screen and (max-width: 980px) {
  .journey { grid-template-columns: 1fr 1fr; }
  .step::after { display: none; }
}
@media screen and (max-width: 600px) { .journey { grid-template-columns: 1fr; } }

/* Architecture diagram */
.arch, .pipeline { margin: 40px 0 0; }
.arch figcaption, .pipeline figcaption { font-family: var(--mono); font-size: 12px; color: var(--dark-muted); margin-bottom: 12px; letter-spacing: .04em; }
.arch__scroll, .pipeline__scroll { overflow-x: auto; padding-bottom: 4px; }
.arch__grid { display: grid; grid-template-columns: 130px 32px 1fr 190px; gap: 12px; align-items: center; min-width: 760px; }
.arch__node { background: var(--dark-surface); border: 1px solid var(--dark-line); border-radius: 10px; padding: 12px 14px; font-size: 12.5px; line-height: 1.6; color: var(--dark-muted); }
.arch__node b { display: block; color: var(--dark-text); font-size: 14px; }
.arch__node--ext { text-align: center; }
.arch__bad { margin-top: 12px; color: #fb923c !important; text-decoration: line-through; text-decoration-thickness: 1px; }
.arch__edge { text-align: center; color: #3cc4ae; font-size: 20px; }
.arch__zone { border: 1.5px dashed #3a4452; border-radius: 14px; padding: 12px 14px 14px; position: relative; }
.arch__zone-label { margin: 0 0 10px; font-family: var(--mono); font-size: 11px; color: var(--dark-muted); letter-spacing: .08em; }
.arch__row { display: grid; grid-template-columns: 1fr 32px 1fr; align-items: center; }
.arch__row--sub { grid-template-columns: 1fr 32px 1fr; margin-top: 10px; }
.arch__row--sub .arch__node { grid-column: 3; }
.arch__node--proxy { border-color: #3cc4ae; box-shadow: 0 0 0 3px rgba(60, 196, 174, .12); }
.arch__node--game { border-color: #4b5667; }
.arch__node--store { border-style: dashed; }
.arch__side { display: grid; gap: 10px; }
.arch__node--code { display: grid; grid-template-columns: 22px 1fr; column-gap: 10px; align-items: center; }
.arch__node--code img { grid-row: span 2; }
.arch__node--code b, .arch__node--code span { grid-column: 2; }

/* Pipeline */
.pipeline__flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 28px; min-width: 760px; }
.pipeline__flow li { position: relative; background: var(--dark-surface); border: 1px solid var(--dark-line); border-radius: 10px; padding: 12px 14px; }
.pipeline__flow li::after { content: "→"; position: absolute; right: -22px; top: 50%; transform: translateY(-50%); color: #3cc4ae; }
.pipeline__flow li:last-child::after { display: none; }
.pipeline__flow b { display: block; font-family: var(--mono); font-size: 13px; color: var(--dark-text); }
.pipeline__flow span { display: block; font-size: 12px; color: var(--dark-muted); line-height: 1.6; margin-top: 4px; }
.pipeline__flow .is-alert { border-color: #fb923c; }
.pipeline__flow .is-alert b { color: #fb923c; }

/* ===== Works ===== */
.works { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.work { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease; }
.work:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(20, 24, 32, .05), 0 16px 36px rgba(20, 24, 32, .1); }
.work__img { aspect-ratio: 16 / 10; overflow: hidden; background: var(--bg-alt); }
.work__img img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.work:hover .work__img img { transform: scale(1.04); }
.work__img--contain img { object-fit: contain; padding: 24px; }
.work__body { padding: 18px 20px 20px; display: flex; flex-direction: column; flex: 1; }
.work__kind { margin: 0; font-size: 12px; color: var(--accent); font-weight: 700; }
.work h3 { margin: 2px 0 8px; font-size: 19px; }
.work__body > p:not(.work__kind):not(.work__links) { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.8; }
.work__links { margin: auto 0 0; padding-top: 14px; display: flex; gap: 16px; font-size: 14px; font-weight: 700; }
.work__links a { text-decoration: none; }
.work__links a:hover { text-decoration: underline; }
.work--wide { grid-column: span 3; flex-direction: row; }
.work--wide .work__img { flex: 0 0 56%; aspect-ratio: auto; min-height: 320px; }
.work--wide .work__img img { object-position: center 55%; }
.work--wide .work__body { padding: 28px 32px; justify-content: center; }
.work--wide h3 { font-size: 28px; }
.work--wide .work__body > p:not(.work__kind):not(.work__links) { font-size: 15px; }
.work--wide .work__links { margin-top: 0; }
@media screen and (max-width: 880px) {
  .works { grid-template-columns: 1fr 1fr; }
  .work--wide { grid-column: span 2; flex-direction: column; }
  .work--wide .work__img { aspect-ratio: 16 / 10; min-height: 0; }
  .work--wide .work__body { padding: 20px; }
}
@media screen and (max-width: 600px) {
  .works { grid-template-columns: 1fr; }
  .work--wide { grid-column: span 1; }
}

/* ===== Contact / Footer ===== */
.contact { text-align: center; background: var(--bg-alt); }
.contact__title { font-size: clamp(28px, 5vw, 44px); margin: 0 0 8px; font-weight: 900; }
.contact p { color: var(--muted); margin: 0 0 28px; }
.footer { padding: 28px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.footer p { margin: 0; }

/* ===== Reveal ===== */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .cursor { animation: none; }
}

/* Oracle のロゴは横長ワードマークなので幅を広げる */
.skill__icons img[src*="oracle"] { width: 58px; height: 32px; }
.step__icon img[src*="oracle"] { width: 96px; height: auto; max-height: none; }
.section--dark { border-block: 1px solid var(--dark-line); }

/* グリッド子要素が長い行（pre 等）で押し広げられないようにする */
.hero__grid > *, .about > *, .skills > *, .works > *, .journey > *, .tl > * { min-width: 0; }

/* ===== Print（ポートフォリオ PDF 用：A4 横・デスクトップレイアウト） ===== */
@page { size: A4 landscape; margin: 10mm 12mm; }
@media print {
  :root {
    --bg: #ffffff; --bg-alt: #f4f3ef; --surface: #ffffff; --text: #1b1d22; --muted: #50555f;
    --line: #dedbd2; --accent: #0f7b6c; --accent-soft: #e2f3ef; --shadow: none;
    color-scheme: light;
  }
  html { font-size: 14px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { font-size: 13.5px; line-height: 1.7; background: #fff; }
  .skill__icons img, .cert img, .icon-aws, .skill__head img { filter: none !important; }
  .nav, .hero__cta, .contact, .cursor { display: none !important; }
  .print-url { display: block !important; }
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  .wrap { max-width: none; padding-inline: 0; }
  .hero { padding: 24px 0 0; }
  .hero__stats { margin-top: 28px; }
  .section { padding: 0; break-before: page; }
  .section--dark { padding: 18px 20px; border-radius: 12px; border: 0; }
  .h2 { margin-bottom: 18px; }
  .section__lead { margin: -10px 0 18px; }
  .tl, .skill, .step, .work, .arch, .pipeline, .cert, .about__facts { break-inside: avoid; }
  .timeline { gap: 12px; }
  .tl__card { padding: 14px 20px; }
  .skills { gap: 12px; }
  .skill { padding: 14px 16px; }
  .journey { gap: 10px; }
  .step { padding: 14px; }
  .step p { font-size: 12px; }
  .arch, .pipeline { margin-top: 16px; }
  .works { gap: 12px; }
  .work { box-shadow: none; }
  .work__img { aspect-ratio: 16 / 8; }
  .work--wide .work__img { min-height: 250px; }
  .work__body { padding: 12px 14px 14px; }
  .work__body > p:not(.work__kind):not(.work__links) { font-size: 12.5px; }
  .work__links a::after { content: " " attr(href); font-weight: 400; font-size: 9px; color: var(--muted); word-break: break-all; }
  .work__links { flex-direction: column; gap: 2px; font-size: 12px; }
  .footer { border: 0; padding-top: 12px; }
}
.print-url { display: none; font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 0 0 10px; }
@media print {
  #about { break-before: auto; margin-top: 26px; }
  #about .h2 { margin-bottom: 12px; }
  .hero__grid { gap: 36px; }
  .hero h1 { font-size: 48px; margin-bottom: 14px; }
  .hero__lead { margin-bottom: 0; font-size: 15px; }
  .term__body { font-size: 12px; padding: 14px 18px; }
  .about__body p { font-size: 13px; }
  .work--wide .work__body { padding: 18px 22px; }
  .work--wide h3 { font-size: 22px; }
}
@media print {
  body { zoom: .74; }
  .works { grid-template-columns: repeat(4, 1fr); }
  .work--wide { grid-column: span 4; }
  .work--wide .work__img { flex-basis: 50%; min-height: 0; aspect-ratio: 16 / 7; }
  .work__img { aspect-ratio: 16 / 9; }
}
.contact__actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.contact__actions .btn { max-width: 100%; }
.js-mail-text { overflow-wrap: anywhere; }
