/* ==============================================================
   Jihoon Jeong — Portfolio
   Visual system: "The datasheet and the board" — see DESIGN.md
   Flat by default. Rules, not shadows. One spot colour.
   ============================================================== */

/* ==============================
   Design Tokens
   ============================== */
:root {
  /* Light — "the datasheet" */
  --accent: #9e2b25;         /* oxide red — annotation ink */
  --accent-deep: #7e1f1b;    /* pressed / hover fill */
  --bg: #edefe9;             /* FR-4 substrate at paper weight */
  --surface: #f7f8f4;        /* raised panel */
  --surface-2: #e4e7de;      /* recessed / inset */
  --border: #c9cec4;         /* the one rule colour */
  --text: #161a17;
  --text-muted: #575e56;

  --radius: 2px;
  --radius-sm: 2px;
  --radius-modal: 3px;

  --lift: 0 16px 32px rgba(22, 26, 23, 0.18); /* detached sheets only */

  --sidebar-w: 280px;
  --content-max: 1100px;
  --measure: 68ch;

  --font-display: 'Archivo', 'Gothic A1', sans-serif;
  --font-body: 'Literata', 'Noto Serif KR', Georgia, serif;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Dark — "the board": matte solder mask + white silkscreen */
[data-theme="dark"] {
  --accent: #e0594a;
  --accent-deep: #f07567;
  --bg: #121412;
  --surface: #1a1d1a;
  --surface-2: #222621;
  --border: #333a32;
  --text: #e4e7e0;
  --text-muted: #9ba398;
  --lift: 0 16px 32px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #e0594a;
    --accent-deep: #f07567;
    --bg: #121412;
    --surface: #1a1d1a;
    --surface-2: #222621;
    --border: #333a32;
    --text: #e4e7e0;
    --text-muted: #9ba398;
    --lift: 0 16px 32px rgba(0, 0, 0, 0.55);
  }
}

/* ==============================
   Reset & Base
   ============================== */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.12s var(--ease);
}
a:hover { color: var(--accent); border-bottom-color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0 0 0.4em;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
h1 { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

p { margin: 0 0 1em; max-width: var(--measure); }

img { max-width: 100%; height: auto; display: block; }

/* Figures are data: always tabular */
.stat-value, .counter, time, td, th { font-variant-numeric: tabular-nums; }

::selection { background: var(--accent); color: var(--surface); }

/* ==============================
   Layout
   ============================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  padding: 32px 24px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 50;
  transition: transform 0.25s var(--ease);
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 56px 48px 80px;
  width: calc(100% - var(--sidebar-w));
}

.container { max-width: var(--content-max); margin: 0 auto; }

/* ==============================
   Sidebar
   ============================== */
.sidebar-profile { text-align: center; margin-bottom: 24px; }

.profile-img {
  width: 118px;
  height: 118px;
  border-radius: 50%;      /* a photograph stays a photograph */
  margin: 0 auto 16px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.profile-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.profile-role {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 auto;
  max-width: none;
}

.sidebar-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  margin: 8px 0;
  color: var(--text);
}
.contact-item .icon {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}
.contact-item .icon svg { width: 100%; height: 100%; display: block; }
.contact-item a { word-break: break-all; }

.sidebar-info {
  border-left: 1px solid var(--border);
  padding: 2px 0 2px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 16px 0;
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
}

.sidebar-nav li + li { border-top: 1px solid var(--border); }

.sidebar-nav a {
  display: block;
  padding: 10px 12px 10px 14px;
  font-family: var(--font-display);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  border-left: 2px solid transparent;
  border-bottom: 0;
  transition: color 0.12s var(--ease), border-color 0.12s var(--ease);
}
.sidebar-nav a:hover { color: var(--accent); border-left-color: var(--border); }
.sidebar-nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* ==============================
   Buttons
   ============================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.12s var(--ease), border-color 0.12s var(--ease),
              background-color 0.12s var(--ease);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: var(--bg);
}

.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ==============================
   Page header / hero
   ============================== */
.page-header { margin-bottom: 32px; }
.page-header h1 {
  color: var(--text);
  padding-top: 14px;
  border-top: 2px solid var(--accent);
  display: inline-block;
}
.page-header .subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

.hero {
  padding: 28px 0 28px;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
.hero h2 { font-size: 1.5rem; margin: 0 0 6px; }
.hero p { margin: 0; color: var(--text-muted); }

/* ==============================
   Cards
   ============================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.12s var(--ease);
}
.card:hover { border-color: var(--accent); }

.card h2, .card h3 { margin-top: 0; font-size: 1.1rem; font-weight: 600; }
.card .meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.card .body { color: var(--text); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.stack-list { display: grid; gap: 16px; }

.card-clickable { cursor: pointer; position: relative; }
.card-clickable::after {
  content: "";
  position: absolute;
  top: 28px;
  right: 24px;
  width: 8px;
  height: 8px;
  border-top: 1.5px solid var(--accent);
  border-right: 1.5px solid var(--accent);
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}
.card-clickable:hover::after { opacity: 1; }

/* Tags — a parts list, not chips */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  margin-top: 12px;
}
.tag {
  padding: 3px 10px;
  border-left: 1px solid var(--border);
  font-family: var(--font-display);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.12s var(--ease);
}
.tag:hover { color: var(--accent); }

/* Sections open on an annotation rule */
.section { margin: 48px 0; }
.section h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  padding-top: 14px;
  border-top: 2px solid var(--accent);
  display: inline-block;
}

.col-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.skill-list { margin: 0; padding: 0; list-style: none; }
.skill-list li { margin: 4px 0; font-size: 1rem; }

.skill-label {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-top: 16px;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ==============================
   Footer
   ============================== */
.footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==============================
   Modal — a sheet lifted off the board
   ============================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 26, 23, 0.6);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding: 60px 16px;
  overflow-y: auto;
  /* Exit is shorter than entry; allow-discrete keeps display:none until the fade ends */
  opacity: 0;
  transition: opacity 150ms var(--ease), display 150ms allow-discrete;
}
.modal-backdrop.open {
  display: flex;
  opacity: 1;
  transition-duration: 180ms;
}
@starting-style { .modal-backdrop.open { opacity: 0; } }

.modal {
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-modal);
  width: 100%;
  max-width: 880px;
  padding: 36px;
  box-shadow: var(--lift);
  position: relative;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}
.modal-backdrop.open .modal {
  opacity: 1;
  transform: translateY(0);
  transition-duration: 220ms;
}
@starting-style {
  .modal-backdrop.open .modal { opacity: 0; transform: translateY(10px); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s var(--ease);
}
.modal-close:hover { color: var(--accent); }
.modal-close svg { width: 14px; height: 14px; display: block; }

.modal h2 {
  margin-top: 0;
  font-size: 1.5rem;
  padding-right: 44px;
}

.modal .gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 20px 0;
}
.modal .gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: border-color 0.12s var(--ease);
}
.modal .gallery img:hover { border-color: var(--accent); }

.modal .video-wrap {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 20px 0;
  border: 1px solid var(--border);
}
.modal .video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.modal video.demo {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.modal .meta-line {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 16px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(18, 20, 18, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 150ms var(--ease), display 150ms allow-discrete;
}
.lightbox.open {
  display: flex;
  opacity: 1;
  transition-duration: 200ms;
}
@starting-style { .lightbox.open { opacity: 0; } }
.lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: var(--radius);
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}
.lightbox.open img {
  opacity: 1;
  transform: scale(1);
  transition-duration: 200ms;
}
@starting-style {
  .lightbox.open img { opacity: 0; transform: scale(0.98); }
}

/* Language / theme switch: a short crossfade instead of a one-frame swap */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 160ms;
  animation-timing-function: var(--ease);
}

/* ==============================
   Fixed controls
   ============================== */
.theme-toggle,
.lang-toggle,
.menu-btn {
  position: fixed;
  top: 18px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  transition: color 0.12s var(--ease), border-color 0.12s var(--ease);
}
.theme-toggle:hover,
.lang-toggle:hover,
.menu-btn:hover { border-color: var(--accent); color: var(--accent); }

.theme-toggle { right: 24px; }
.theme-toggle svg,
.menu-btn svg { width: 17px; height: 17px; display: block; }

.lang-toggle {
  right: 72px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.menu-btn { display: none; left: 18px; }

/* ==============================
   Responsive
   ============================== */
@media (max-width: 960px) {
  :root { --sidebar-w: 260px; }
  .main { padding: 56px 32px 80px; }
}

@media (max-width: 768px) {
  .menu-btn { display: flex; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--lift); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; width: 100%; padding: 72px 20px 60px; }
  .modal { padding: 28px 22px; }
  .page-header h1 { font-size: 1.5rem; }
}

/* Reveal-on-scroll */
.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 300ms var(--ease), transform 300ms var(--ease);
}
.reveal.in { opacity: 1; transform: translateY(0); }

/* ==============================
   Home hero
   ============================== */
.hero-xl {
  position: relative;
  padding: 8px 0 56px;
  border-bottom: 1px solid var(--border);
}

.hero-name {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.hero-name .grad { color: var(--accent); }

.hero-roles {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  color: var(--text-muted);
  margin: 0 0 20px;
  min-height: 1.6em;
  font-weight: 500;
  max-width: none;
}
.hero-roles .typed {
  color: var(--text);
  font-weight: 600;
  border-right: 2px solid var(--accent);
  padding-right: 2px;
  animation: caret 1s step-end infinite;
}
@keyframes caret { 50% { border-color: transparent; } }

.hero-bio {
  max-width: var(--measure);
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0 0 28px;
  line-height: 1.75;
}

.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }

/* Availability marker — a status LED, not a pill */
.hero-status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 28px;
  padding-top: 14px;
  border-top: 2px solid var(--accent);
  max-width: max-content;
}
.hero-status .pulse {
  width: 7px;
  height: 7px;
  flex: none;
  background: var(--accent);
  border-radius: 50%;
}

/* ==============================
   Stats — a ruled parameter row
   ============================== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 32px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.stat {
  padding: 20px 18px;
  border-left: 1px solid var(--border);
}
.stat:first-child { border-left: 0; }
.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

/* ==============================
   Scroll progress
   ============================== */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: var(--accent);
  z-index: 200;
  pointer-events: none;
  transition: transform 0.08s linear;
}

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal,
  .typed,
  .scroll-progress {
    animation: none !important;
    transition: none !important;
  }
  .reveal { opacity: 1; transform: none; }
  /* Overlays still fade, they just don't move */
  .modal,
  .modal-backdrop.open .modal,
  .lightbox img,
  .lightbox.open img { transform: none; }
  @starting-style {
    .modal-backdrop.open .modal,
    .lightbox.open img { transform: none; }
  }
}
