/* ===========================================================
   Hugo — portfolio
   Two-panel layout: content left, autoplaying ASCII portrait right.
   =========================================================== */

:root {
  --bg:            #f2f2f2;
  --surface:       #ffffff;
  --ink:           #111111;
  --ink-soft:      #3d3d3d;
  --ink-muted:     #6b6b6b;
  --chip:          #f0f0f0;
  --chip-ink:      #4a4a4a;
  --line:          rgba(17, 17, 17, .06);

  --radius-card:   12px;
  --radius-chip:   7px;

  --pad-x:         clamp(24px, 3.2vw, 40px);
  --pad-y:         clamp(28px, 3.4vw, 44px);

  --ease:          cubic-bezier(.22, .61, .36, 1);
  --panel-w:       43.5%;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
svg { display: block; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 12px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
}
.skip-link:focus-visible { left: 12px; }

/* ── Layout ───────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  min-height: 100vh;
  min-height: 100svh;
}

.panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(40px, 6vh, 80px);
  padding: var(--pad-y) var(--pad-x);
  min-width: 0;
}

/* ── Intro ────────────────────────────────────────────────── */

.name {
  margin: 0 0 18px;
  font-size: clamp(30px, 2.6vw, 38px);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.bio {
  margin: 0;
  max-width: 64ch;
  font-size: clamp(14px, 1.02vw, 15.5px);
  line-height: 1.58;
  color: var(--ink-soft);
}

/* ── Selected works ───────────────────────────────────────── */

.section-title {
  margin: 0 0 14px;
  font-size: clamp(16px, 1.25vw, 18px);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.work-list { display: flex; flex-direction: column; gap: 8px; }

.work {
  position: relative;
  width: 100%;
  margin: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  min-width: 0;
  transition:
    transform .32s var(--ease),
    box-shadow .32s var(--ease),
    border-color .32s var(--ease);
}

.work:hover,
.work:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(17, 17, 17, .12);
  box-shadow: 0 6px 20px -8px rgba(0, 0, 0, .18);
  outline: none;
}
.work:focus-visible { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }
.work:active { transform: translateY(0); }

.work__index {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
  min-width: 22px;
}

/* Each logo ships its own black rounded tile, so the badge is just a frame. */
.work__badge {
  display: block;
  width: 26px;
  height: 26px;
  flex: none;
  transition: transform .4s var(--ease);
}
.work__badge img { width: 100%; height: 100%; display: block; }
.work:hover .work__badge { transform: scale(1.06) rotate(-3deg); }

.work__name {
  font-size: 15px;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.work__tag {
  padding: 5px 9px;
  border-radius: var(--radius-chip);
  background: var(--chip);
  color: var(--chip-ink);
  font-size: 12.5px;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background .32s var(--ease), color .32s var(--ease);
}
.work:hover .work__tag { background: var(--ink); color: #fff; }

.work__arrow {
  width: 0;
  opacity: 0;
  color: var(--ink);
  transform: translateX(-6px);
  transition: opacity .3s var(--ease), transform .3s var(--ease), width .3s var(--ease);
}
.work__arrow svg { width: 17px; height: 17px; }
.work:hover .work__arrow,
.work:focus-visible .work__arrow { width: 17px; opacity: 1; transform: translateX(0); }

/* ── Contact ──────────────────────────────────────────────── */

.contact { display: flex; flex-direction: column; gap: 10px; }

.mailto {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-card);
  font-size: 15px;
  letter-spacing: -0.012em;
  transition: transform .32s var(--ease), box-shadow .32s var(--ease), background .32s var(--ease);
}
.mailto:hover { transform: translateY(-1px); box-shadow: 0 10px 26px -12px rgba(0, 0, 0, .6); }
.mailto:active { transform: translateY(0); }
.mailto:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }

.mailto__icon svg { width: 21px; height: 21px; }
.mailto__arrow svg { width: 20px; height: 20px; transition: transform .35s var(--ease); }
.mailto:hover .mailto__arrow svg { transform: translateX(4px); }

.copy {
  align-self: flex-start;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--ink-muted);
  font: inherit;
  font-size: 12.5px;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: color .25s var(--ease);
}
.copy:hover { color: var(--ink); }
.copy:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.copy.is-copied { color: var(--ink); }

/* ── Portrait panel ───────────────────────────────────────── */

.portrait {
  position: relative;
  overflow: hidden;
  background: #fff;
}

.portrait__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  /* The source is a white-paper grid: nudge contrast so it sits cleanly next to the panel. */
  filter: contrast(1.03);
}

/* Soft vignette so the hard video edge melts into the left panel. */
.portrait__grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(242, 242, 242, .4) 0%, rgba(242, 242, 242, 0) 4%);
}

/* ── Entrance ─────────────────────────────────────────────── */

.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: rise .8s var(--ease) forwards;
}
.reveal:nth-of-type(1) { animation-delay: .05s; }
.works.reveal  { animation-delay: .16s; }
.contact.reveal { animation-delay: .26s; }

@keyframes rise {
  to { opacity: 1; transform: none; }
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 1100px) {
  :root { --panel-w: 48%; }
  .work { gap: 12px; padding: 11px 13px; }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 44svh auto;
  }
  .portrait { order: -1; }
  .portrait__video { object-position: center 36%; }
  .portrait__grain {
    background: linear-gradient(180deg, rgba(242, 242, 242, 0) 94%, rgba(242, 242, 242, .7) 100%);
  }
  .panel { gap: 36px; padding-bottom: calc(var(--pad-y) + env(safe-area-inset-bottom)); }
  .name { font-size: 30px; }
  .work__arrow { display: none; }
}

@media (max-width: 420px) {
  .work { gap: 11px; padding: 11px 12px; }
  .work__index { min-width: 20px; font-size: 14px; }
  .work__name { font-size: 14.5px; }
  .work__tag { font-size: 11.5px; padding: 4px 8px; }
  .mailto { font-size: 13.5px; gap: 10px; padding: 15px 16px; }
}

/* ── Preferences ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}


/* ═══════════════════════ Case-study modal ═══════════════════════ */

.modal {
  width: min(1580px, 100% - 7vw);
  max-height: min(1100px, 100svh - 7vh);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: clamp(16px, 1.7vw, 26px);
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
}
.modal[open] { display: flex; }

.modal::backdrop { background: rgba(17, 17, 17, .14); }

.modal__inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  padding: clamp(20px, 2.5vw, 40px);
}
/* Opening focuses the panel so the close button doesn't start ringed; the
   panel itself is not interactive, so it needs no ring of its own. */
.modal__inner:focus { outline: none; }

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: clamp(28px, 5vh, 76px);
}

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

.chip {
  margin: 0;
  padding: clamp(7px, .7vw, 11px) clamp(12px, 1.2vw, 19px);
  border-radius: 10px;
  background: var(--chip);
  color: var(--ink);
  font-size: clamp(14px, 1.26vw, 19px);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
}
.chip--title { background: #e6e6e6; }

.modal__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -6px -6px 0 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.modal__close svg { width: clamp(24px, 2vw, 31px); height: clamp(24px, 2vw, 31px); }
.modal__close:hover { background: var(--chip); }
.modal__close:active { transform: scale(.94); }
.modal__close:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.modal__body {
  flex: 1;
  min-height: 0;
  display: grid;
  align-content: center;
  align-content: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: clamp(8px, 2vh, 28px);
}

/* ── Case-study screenshot ───────────────────────────────────────
   One composed PNG per project, with transparent gaps between the
   panels — so no background, border or radius here; the card shows
   through exactly as the design intends.

   Each shot renders at its own pixel size, never scaled up or down.
   Only a card too narrow to hold it shrinks it; a card too short to
   hold it scrolls.                                                   */

.shot {
  display: block;
  width: min(var(--shot-w), 100%);
  height: auto;
  margin-inline: auto;
}

/* aspect-ratio holds the box before the image arrives, so opening a modal
   never reflows. Values are the files' own pixel dimensions. */
.shot--bitcastle       { --shot-w: 1226px; aspect-ratio: 1226 / 764; }
.shot--thesis-exchange { --shot-w: 1335px; aspect-ratio: 1335 / 733; }
.shot--scanium         { --shot-w: 1204px; aspect-ratio: 1204 / 853; }
.shot--oraidex         { --shot-w:  996px; aspect-ratio:  996 / 827; }
.shot--galax           { --shot-w: 1264px; aspect-ratio: 1264 / 822; }

/* ── Motion ───────────────────────────────────────────────────── */

.modal[open]            { animation: modal-in .28s var(--ease); }
.modal[open]::backdrop   { animation: fade-in .28s var(--ease); }
.modal.is-closing           { animation: modal-out .18s var(--ease) forwards; }
.modal.is-closing::backdrop { animation: fade-in .18s var(--ease) reverse forwards; }

@keyframes modal-in  { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes modal-out { to   { opacity: 0; transform: translateY(8px)  scale(.99);  } }
@keyframes fade-in   { from { opacity: 0; } }

html.is-locked { overflow: hidden; }

/* ── Modal responsive ─────────────────────────────────────────── */

/* On a phone the modal is a bottom sheet: full width, pinned to the bottom
   edge, rounded only along the top, over a much heavier scrim. */
@media (max-width: 860px) {
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 88svh;
    margin: auto auto 0;
    border-radius: 22px 22px 0 0;
  }

  .modal::backdrop { background: rgba(17, 17, 17, .7); }

  .modal__inner {
    padding: 22px 20px calc(48px + env(safe-area-inset-bottom));
  }
  .modal__head { margin-bottom: 44px; }
  .modal__body { align-content: safe center; }

  /* A sheet slides, it doesn't rise and scale. */
  .modal[open]      { animation: sheet-in .34s var(--ease); }
  .modal.is-closing { animation: sheet-out .22s var(--ease) forwards; }
}

@keyframes sheet-in  { from { transform: translateY(100%); } }
@keyframes sheet-out { to   { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  .modal[open], .modal[open]::backdrop,
  .modal.is-closing, .modal.is-closing::backdrop { animation: none; }
}
