@layer tokens, base, components, utilities;

@layer tokens {
  :root {
    color-scheme: dark;
    --bg: #1c1a17;
    --surface: #211e1a;
    --line: #332c22;
    --line-strong: #4a4238;
    --ink: #f0e8db;
    --muted: #a39a8c;
    --dim: #6b6255;
    --accent: #c96f4a;
    --accent-soft: #e0906a;
    --display: "Instrument Serif", Georgia, "Times New Roman", serif;
    --sans: "Public Sans", system-ui, -apple-system, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, monospace;
  }
}

@property --shine {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

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

  html {
    scroll-behavior: smooth;
  }

  body {
    margin: 0;
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    overflow-x: hidden;
  }

  p {
    margin: 0;
  }

  a {
    color: var(--accent);
    text-decoration: none;
  }
  a:hover {
    color: var(--accent-soft);
  }

  hr {
    border: 0;
    border-top: 0.5px solid var(--line);
    margin: 0;
  }
}

@layer components {
  .glow {
    position: fixed;
    top: -160px;
    right: -120px;
    width: 520px;
    height: 420px;
    z-index: 0;
    pointer-events: none;
    background: conic-gradient(
      from var(--shine),
      transparent 0deg,
      color-mix(in oklab, var(--accent) 26%, transparent) 90deg,
      transparent 200deg
    );
    animation: shine 28s linear infinite;
    filter: blur(46px);
  }

  @keyframes shine {
    to {
      --shine: 360deg;
    }
  }

  .grain {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.5;
    pointer-events: none;
  }

  /* ---------- header ---------- */

  .site-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: clamp(18px, 2vw, 24px) clamp(20px, 4vw, 56px);
    border-bottom: 0.5px solid var(--line);
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
  }

  .brand:hover {
    color: var(--ink);
  }

  .brand span {
    font-family: var(--display);
    font-size: 21px;
    letter-spacing: 0.01em;
  }

  .site-nav {
    display: flex;
    align-items: center;
    gap: clamp(18px, 2.4vw, 30px);
  }

  .site-nav a {
    font-size: 13px;
    color: var(--muted);
  }

  .site-nav a:hover {
    color: var(--ink);
  }

  .site-nav a.pill {
    color: var(--ink);
    border: 0.5px solid var(--line-strong);
    border-radius: 999px;
    padding: 7px 16px;
  }

  .site-nav a.pill:hover {
    border-color: var(--accent);
  }

  .menu-toggle {
    display: none;
    position: relative;
    z-index: 3;
    background: none;
    border: none;
    color: var(--muted);
    padding: 6px;
    cursor: pointer;
  }

  .menu-toggle .bar {
    transform-origin: 12px 12px;
    transition:
      transform 0.3s ease,
      opacity 0.2s ease;
  }

  .menu-toggle.is-open {
    color: var(--ink);
  }

  .menu-toggle.is-open .bar-top {
    transform: translateY(4px) rotate(45deg);
  }

  .menu-toggle.is-open .bar-bottom {
    transform: translateY(-4px) rotate(-45deg);
  }

  .mobile-nav {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 44px;
    background: var(--bg);
    opacity: 0;
    transition: opacity 0.32s ease;
  }

  .mobile-nav.is-open {
    display: flex;
    opacity: 1;
  }

  .mobile-nav-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: none;
    color: var(--ink);
    font-size: 1.4rem;
    cursor: pointer;
  }

  .mobile-nav-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .mobile-nav a {
    font-family: var(--display);
    font-size: 34px;
    color: var(--ink);
    padding: 8px 20px;
    opacity: 0;
    translate: 0 14px;
    transition:
      opacity 0.4s ease,
      translate 0.4s ease;
  }

  .mobile-nav.is-open a {
    opacity: 1;
    translate: 0 0;
  }

  .mobile-nav.is-open a {
    transition-delay: calc(var(--i) * 60ms + 80ms);
  }

  .mobile-nav a:hover {
    color: var(--accent);
  }

  .mobile-nav-socials {
    display: flex;
    gap: 22px;
    opacity: 0;
    translate: 0 14px;
    transition:
      opacity 0.4s ease,
      translate 0.4s ease;
  }

  .mobile-nav.is-open .mobile-nav-socials {
    opacity: 1;
    translate: 0 0;
  }

  .mobile-nav.is-open .mobile-nav-socials {
    transition-delay: calc(var(--i) * 60ms + 80ms);
  }

  .mobile-nav-socials a {
    color: var(--muted);
    padding: 6px;
  }

  .mobile-nav-socials a:hover {
    color: var(--accent);
  }

  @media (prefers-reduced-motion: reduce) {
    .mobile-nav,
    .mobile-nav a,
    .mobile-nav-socials {
      transition: none;
    }
  }

  /* ---------- hero ---------- */

  .hero {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    gap: clamp(28px, 4vw, 56px);
    align-items: start;
    padding: clamp(44px, 5vw, 68px) clamp(20px, 4vw, 56px)
      clamp(36px, 4vw, 52px);
  }

  .eyebrow {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 20px;
  }

  .hero h1 {
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(38px, 4.6vw, 62px);
    line-height: 1.06;
    color: var(--ink);
    margin: 0 0 22px;
    text-wrap: balance;
  }

  .hero h1 .dash {
    color: var(--accent-soft);
  }

  .hero h1 em {
    font-style: italic;
    color: var(--muted);
  }

  .lede {
    font-size: 16px;
    color: var(--muted);
    line-height: 1.7;
    max-width: 52ch;
    margin-bottom: 30px;
    text-wrap: pretty;
  }

  .hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
  }

  .btn {
    font-family: var(--sans);
    border-radius: 999px;
    padding: 12px 26px;
    font-size: 14px;
    font-weight: 500;
    display: inline-block;
  }

  .btn-primary {
    background: var(--accent);
    color: #f5ede4;
    border: none;
  }

  .btn-primary:hover {
    background: var(--accent-soft);
    color: #2a1a10;
  }

  .btn-ghost {
    background: transparent;
    color: var(--ink);
    border: 0.5px solid var(--line-strong);
  }

  .btn-ghost:hover {
    border-color: var(--accent);
    color: var(--ink);
  }

  .currently {
    border: 0.5px solid var(--line);
    border-radius: 14px;
    padding: 22px 24px;
    background: color-mix(in oklab, var(--surface) 88%, transparent);
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .currently .label {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--dim);
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }

  .currently .row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: baseline;
  }

  .currently .k {
    font-size: 12.5px;
    color: var(--dim);
  }

  .currently .v {
    font-size: 13.5px;
    color: var(--ink);
  }

  /* ---------- work / cards ---------- */

  .work {
    container-type: inline-size;
    position: relative;
    z-index: 1;
    padding: 0 clamp(20px, 4vw, 56px) clamp(36px, 4vw, 54px);
  }

  .section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 22px;
  }

  .section-head .label {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }

  .section-head .count {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--dim);
    letter-spacing: 0.1em;
  }

  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(272px, 1fr));
    grid-template-rows: repeat(4, auto);
    gap: 18px;
  }

  .card {
    grid-row: span 4;
    display: grid;
    grid-template-rows: subgrid;
    gap: 12px;
    background: var(--surface);
    border: 0.5px solid var(--line);
    border-radius: 14px;
    padding: 22px;
    color: var(--ink);
    transition:
      border-color 0.35s ease,
      background 0.35s ease,
      opacity 0.35s ease,
      translate 0.3s ease;
  }

  .card:hover {
    border-color: color-mix(in oklab, var(--accent) 45%, var(--line));
    background: color-mix(in oklab, var(--accent) 5%, var(--surface));
    translate: 0 -2px;
  }

  .card:hover .arrow {
    translate: 5px 0;
    color: var(--accent);
  }

  .card.is-wip:hover {
    border-color: var(--line);
    background: var(--surface);
    translate: 0 0;
  }

  .grid:has(.card:hover) .card:not(:hover) {
    opacity: 0.62;
  }

  @container (max-width: 700px) {
    .grid {
      grid-template-columns: 1fr;
      grid-template-rows: none;
    }

    .grid > .card {
      grid-row: auto;
      display: flex;
      flex-direction: column;
    }
  }

  .card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .card .num {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--dim);
    letter-spacing: 0.1em;
  }

  .card .tag {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--accent);
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .card .title {
    font-family: var(--display);
    font-size: 25px;
    color: var(--ink);
    line-height: 1.15;
  }

  .card .desc {
    font-size: 13.5px;
    color: var(--muted);
    line-height: 1.6;
    text-wrap: pretty;
  }

  .card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

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

  .chip {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--muted);
    border: 0.5px solid var(--line);
    border-radius: 999px;
    padding: 4px 10px;
  }

  .arrow {
    color: var(--dim);
    flex-shrink: 0;
    transition:
      translate 0.35s ease,
      color 0.35s ease;
  }

  /* ---------- contact ---------- */

  .contact {
    position: relative;
    z-index: 1;
    padding: 0 clamp(20px, 4vw, 56px) clamp(36px, 4vw, 54px);
  }

  .contact-layout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
  }

  .contact-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border: 0.5px solid var(--line);
    border-radius: 14px;
    padding: 26px;
  }

  .contact-mark {
    flex-shrink: 0;
    opacity: 0;
  }

  .contact-mark.is-visible {
    animation: slide-in 800ms ease-out 1 forwards;
  }

  @media (max-width: 860px) {
    .contact-layout {
      flex-direction: column;
    }
  }

  .contact-form .field {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .contact-form label {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  .contact-form input,
  .contact-form textarea {
    font-family: var(--sans);
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
    border: 0.5px solid var(--line);
    border-radius: 10px;
    padding: 11px 14px;
    transition: border-color 0.25s ease;
  }

  .contact-form input::placeholder,
  .contact-form textarea::placeholder {
    color: var(--dim);
  }

  .contact-form input:focus,
  .contact-form textarea:focus {
    outline: none;
    border-color: var(--accent);
  }

  .contact-form textarea {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
  }

  .contact-form .btn {
    align-self: flex-start;
    border: none;
    cursor: pointer;
  }

  /* ---------- footer ---------- */

  .site-footer {
    position: relative;
    z-index: 1;
    padding: 0 clamp(20px, 4vw, 56px) 26px;
  }

  .outline-name {
    font-family: var(--display);
    font-size: clamp(44px, 9vw, 118px);
    line-height: 1;
    margin-bottom: 18px;
    -webkit-text-stroke: 1px color-mix(in oklab, var(--ink) 22%, transparent);
    color: transparent;
    user-select: none;
  }

  .site-footer hr {
    margin-bottom: 16px;
  }

  .footer-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .fine {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--dim);
  }

  .fine a {
    color: var(--dim);
  }

  .fine a:hover {
    color: var(--accent);
  }

  .socials {
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .socials a {
    color: var(--dim);
  }
  .socials a:hover {
    color: var(--accent);
  }
}

@layer utilities {
  @supports (animation-timeline: view()) {
    .card {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 4% cover 24%;
    }
  }

  @keyframes rise {
    from {
      opacity: 0.001;
      translate: 0 16px;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }

  @keyframes slide-in {
    from {
      translate: 150vw 0;
      scale: 200% 1;
      opacity: 0;
    }

    to {
      translate: 0 0;
      scale: 100% 1;
      opacity: 0.55;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }
    .glow,
    .card {
      animation: none;
    }
  }
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .site-nav {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-nav.is-open {
    display: flex;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .brand span {
    font-size: 18px;
  }
}
