:root {
  --bg: #ffffff;
  --bg-subtle: #f7f7f5;
  --text: #17181a;
  --text-muted: #5b5e63;
  --border: #e7e7e4;
  --accent: #2f5233;
  --accent-soft: #eef2ec;
  --max-width: 760px;
  --max-width-wide: 980px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121314;
    --bg-subtle: #1a1b1d;
    --text: #f2f2f0;
    --text-muted: #9a9da2;
    --border: #2a2b2d;
    --accent: #8fbf98;
    --accent-soft: #1c2620;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.wrap.wide { max-width: var(--max-width-wide); }

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.92em;
}

/* Loader */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.45s ease;
}

#loader.loader-hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-mark {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
}

.loader-caret {
  color: var(--accent);
  animation: blink 0.9s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}

.logo {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 15px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

nav {
  display: flex;
  gap: 20px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

nav::-webkit-scrollbar { display: none; }

nav a { flex-shrink: 0; }

nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s ease;
}

nav a:hover { color: var(--text); }

/* Japan intro / quote */
.japan-intro {
  position: relative;
  height: 100vh;
  min-height: 420px;
  max-height: 760px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  --fade: 1;
}

@supports (height: 100dvh) {
  .japan-intro { height: 100dvh; }
}

.japan-intro-bg {
  position: absolute;
  inset: -6% -6%;
  background-size: cover;
  background-position: center 42%;
  background-repeat: no-repeat;
  opacity: var(--fade);
  transform: translateY(calc((1 - var(--fade)) * -32px)) scale(1.02);
  will-change: opacity, transform;
}

.japan-intro-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15,28,20,0.28), rgba(15,28,20,0.5) 60%, rgba(17,32,23,0.86));
  opacity: var(--fade);
}

.japan-intro-content {
  position: relative;
  text-align: center;
  color: #fdfdfb;
  opacity: var(--fade);
  transform: translateY(calc((1 - var(--fade)) * -18px));
}

.jp-quote {
  font-size: 46px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0 0 16px;
}

.jp-quote-en {
  font-size: 19px;
  font-style: italic;
  margin: 0 0 8px;
  color: rgba(253,253,251,0.92);
}

.jp-quote-note {
  font-size: 14px;
  color: rgba(253,253,251,0.68);
  margin: 0;
}

@media (max-width: 600px) {
  .jp-quote { font-size: 34px; }
  .jp-quote-en { font-size: 16px; }
}

/* Career map timeline */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 32px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -28px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--text-muted);
}

.timeline-dot-accent {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.timeline-dot-current {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.timeline-date {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.timeline-item h3 {
  font-size: 16px;
  margin: 0 0 2px;
}

.timeline-org {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* Hero */
.hero {
  position: relative;
  min-height: 86vh;
  max-height: 900px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background: #112017;
  color: #f2f2f0;
}

@supports (min-height: 86dvh) {
  .hero { min-height: 86dvh; }
}

.hero-pattern {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 20%, rgba(143,191,152,0.22), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(143,191,152,0.14), transparent 45%),
    radial-gradient(rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: auto, auto, 26px 26px;
  background-position: 0 0, 0 0, 0 0;
}

.jp-line {
  font-family: "Noto Serif JP", serif;
  font-weight: 500;
  font-size: 21px;
  letter-spacing: 0.03em;
  color: #cdeed3;
  margin: 0 0 24px;
}

.hero-inner {
  padding-bottom: 72px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 12px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.hero .eyebrow { color: #b9e0c1; }

h1 {
  font-size: 48px;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.hero-summary {
  color: rgba(242,242,240,0.86);
  font-size: 17px;
  max-width: 58ch;
  margin: 0 0 22px;
}

.hero-links {
  font-size: 14px;
  color: rgba(242,242,240,0.75);
}

.hero-links a {
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.35);
}

.hero-links a:hover { border-color: #fff; }

.dot { margin: 0 8px; opacity: 0.5; }

.scroll-cue {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 34px;
  border: 2px solid rgba(255,255,255,0.55);
  border-radius: 12px;
}

.scroll-cue span {
  display: block;
  width: 4px;
  height: 8px;
  background: #fff;
  border-radius: 2px;
  margin: 6px auto 0;
  animation: scrollcue 1.6s ease infinite;
}

@keyframes scrollcue {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(12px); opacity: 0; }
  100% { opacity: 0; }
}

/* Sections */
.section {
  padding: 56px 24px;
  border-top: 1px solid var(--border);
}

h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 28px;
}

.section-lede {
  color: var(--text-muted);
  font-size: 15px;
  margin: -20px 0 28px;
}

/* Jobs */
.job { margin-bottom: 40px; }
.job:last-child { margin-bottom: 0; }

.job-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 6px;
}

.job-head h3 {
  font-size: 17px;
  margin: 0 0 2px;
}

.job-org {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

.job-date {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.job-sub {
  font-weight: 600;
  font-size: 14.5px;
  margin: 18px 0 8px;
}

.job ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.job li {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 6px;
}

.tech-tags {
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tech-tags span {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Projects */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.project-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 12px 24px -18px color-mix(in srgb, var(--accent) 60%, transparent);
}

.project-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.project-card h3 {
  font-size: 16px;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.gh-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.gh-link:hover { text-decoration: underline; }

.project-card p {
  font-size: 14.5px;
  color: var(--text-muted);
  margin: 0;
}

/* Skills grid */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.skill-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  transition: border-color 0.2s ease;
}

.skill-card:hover { border-color: var(--accent); }

.skill-card h3 {
  font-size: 13px;
  margin: 0 0 6px;
  color: var(--accent);
}

.skill-card p {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

/* Certifications */
.cert-list {
  margin: 20px 0 0;
  padding-left: 20px;
}

.cert-list li {
  font-size: 14.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.cert-list strong { color: var(--text); }

.languages {
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-muted);
}

.languages strong { color: var(--accent); }

/* Contact */
.contact-section p {
  color: var(--text-muted);
  font-size: 15px;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.contact-links a {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.contact-links a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
}

.site-footer p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .hero { min-height: 76vh; }
  .hero-inner { padding-bottom: 44px; }
  h1 { font-size: 32px; }
  .jp-line { font-size: 18px; }
  .job-head { flex-direction: column; gap: 2px; }
  nav { gap: 12px; }
  nav a { font-size: 13px; }
  .section-lede { margin-top: -14px; }
}

@supports (min-height: 76dvh) {
  @media (max-width: 600px) {
    .hero { min-height: 76dvh; }
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .wrap { padding: 0 16px; }
  h1 { font-size: 27px; }
  .jp-quote { font-size: 28px; }
  .hero-summary { font-size: 15.5px; }
  nav { gap: 10px; }
  nav a { font-size: 12.5px; }
}

/* Landscape phones: viewport height is tight, don't force a near-full-height banner */
@media (max-height: 480px) and (orientation: landscape) {
  .hero, .japan-intro { min-height: auto; height: auto; padding-top: 64px; padding-bottom: 64px; }
  .scroll-cue { display: none; }
}
