/* Far East Studios — one page.
   Authored mobile-first; every media query is min-width. */

/* ---------- Fonts ---------- */
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('assets/fonts/cormorant-garamond-300.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
/* Google serves Inter as one variable file; 400 and 500 come from the same face. */
@font-face {
  font-family: 'Inter';
  src: url('assets/fonts/inter.woff2') format('woff2');
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}

/* Drives the hero's paint-on mask. Must stay at the top level — @property is
   invalid nested inside @media and would be dropped. */
@property --sweep {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

/* ---------- Tokens ---------- */
:root {
  --paper: #FAF8F4;
  --paper-2: #F2EFE9;
  --ink: #16161A;
  --ink-soft: #3A3A42;
  --muted: #6B6B73;
  --hairline: #DEDAD2;
  --seal: #9A3B2E;

  --enso-invert: 0;
  --grain-opacity: 0.035;
  --bleed-opacity: 0.07;
  --bleed-blend: multiply;

  --serif: 'Cormorant Garamond', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --fs-11: 0.6875rem;
  --fs-13: 0.8125rem;
  --fs-15: 0.9375rem;
  --fs-17: 1.0625rem;
  --fs-21: 1.3125rem;
  --fs-28: 1.75rem;
  --fs-40: 2.5rem;
  --fs-display: clamp(2.25rem, 7vw, 6rem);

  --s1: 8px;  --s2: 16px; --s3: 24px; --s4: 40px;
  --s5: 64px; --s6: 96px; --s7: 160px;

  --container: 1180px;
  --gutter: 20px;
  --section-y: var(--s6);
  --measure: 62ch;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0D0D0F;
    --paper-2: #141417;
    --ink: #E8E4DC;
    --ink-soft: #B8B4AC;
    --muted: #8E8A82;
    --hairline: #26262B;
    --seal: #CF6049;

    --enso-invert: 1;
    --grain-opacity: 0.05;
    --bleed-opacity: 0.1;
    --bleed-blend: screen;
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, p, figure, blockquote, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
img { max-width: 100%; height: auto; display: block; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-17);
  font-weight: 400;
  line-height: 1.65;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: color-mix(in srgb, var(--seal) 22%, transparent); }

:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 3px;
  border-radius: 1px;
}

/* ---------- Shared pieces ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  /* fixed, not absolute — absolute would place it at the document top, so
     tabbing to it from further down the page would focus something unseen. */
  position: fixed;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--paper);
  color: var(--ink);
  padding: 12px 20px;
  border: 1px solid var(--hairline);
  font-size: var(--fs-15);
}
.skip:focus { left: var(--gutter); top: var(--gutter); }

.eyebrow {
  font-size: var(--fs-11);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--seal);
  margin-bottom: var(--s3);
}

/* Every rule stops short of the container edge — the ensō's opening, made structural. */
.rule {
  height: 1px;
  background: var(--hairline);
  border: 0;
  margin-right: clamp(24px, 14vw, 200px);
}

.section {
  padding-block: var(--section-y);
}

.section-head { margin-bottom: var(--s5); }
.section-head h2 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(1.75rem, 4.5vw, var(--fs-40));
  line-height: 1.15;
  letter-spacing: -0.015em;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.bleed {
  position: fixed;
  top: 0;
  left: 0;
  width: 420px;
  height: 420px;
  margin: -210px 0 0 -210px;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: var(--bleed-blend);
  background: radial-gradient(circle closest-side,
    color-mix(in srgb, var(--seal) 60%, var(--ink)) 0%, transparent 70%);
  transition: opacity 1100ms var(--ease);
  will-change: transform;
}

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease), visibility 700ms;
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  border-bottom: 1px solid var(--hairline);
  padding-top: env(safe-area-inset-top);
}
@supports (backdrop-filter: blur(14px)) {
  .site-header { backdrop-filter: blur(14px); }
}
.site-header.is-visible { opacity: 1; visibility: visible; transform: none; }

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  padding-block: 10px;
}
.brand-mark { width: 26px; height: 26px; filter: invert(var(--enso-invert)); }
.brand-word {
  font-size: var(--fs-11);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
}

.site-nav { display: flex; gap: var(--s2); }
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: var(--fs-13);
  padding: 12px 4px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: color 400ms var(--ease);
}
.site-nav a:hover, .site-nav a:focus-visible { color: var(--ink); }
/* Scoped to .site-nav so it outranks `.site-nav a { display: inline-flex }`. */
.site-nav .nav-wide { display: none; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: clip;
  min-height: 92svh;
  display: flex;
  align-items: center;
  padding-block: calc(var(--s6) + env(safe-area-inset-top)) var(--s6);
}
.hero .container { position: relative; z-index: 2; }

.hero-enso-wrap {
  position: absolute;
  z-index: 0;
  top: -5%;
  right: -20vw;
  width: 88vw;
  pointer-events: none;
  transition: opacity 1100ms var(--ease);
}
.js .hero-enso-wrap { opacity: 0; }
.js .hero-enso-wrap.is-lit { opacity: 1; }
.hero-enso {
  width: 100%;
  height: auto;
  filter: invert(var(--enso-invert));
  opacity: 0.05;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: var(--fs-display);
  line-height: 1.12;
  letter-spacing: -0.02em;
  max-width: 16ch;
  /* Breaks the line on its own hinge — the comma — rather than stranding "we"
     away from its verb. Unsupported browsers fall back to a fine natural rag. */
  text-wrap: balance;
  margin-bottom: var(--s3);
}
.hero-lead {
  color: var(--ink-soft);
  max-width: 46ch;
  margin-bottom: var(--s4);
}
.hero .rule { margin-bottom: var(--s2); }
.hero-meta {
  font-size: var(--fs-13);
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ---------- Statement ---------- */
.statement { background: var(--paper-2); }
.statement p {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(1.5rem, 4.2vw, 2.25rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
  max-width: 24ch;
  color: var(--ink);
}
.statement p + p { margin-top: var(--s3); color: var(--ink-soft); max-width: 30ch; }

/* ---------- Services ---------- */
.services-list { border-top: 1px solid var(--hairline); }
.service {
  position: relative;
  display: block;
  padding-block: var(--s3);
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-soft);
  transition: color 700ms var(--ease);
}
.service::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 1px;
  background: var(--seal);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 700ms var(--ease);
}
.service-num {
  display: block;
  font-size: var(--fs-11);
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--seal);
  margin-bottom: 6px;
}
.service-name {
  font-size: var(--fs-21);
  font-weight: 400;
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: 6px;
}
.service-detail {
  font-size: var(--fs-15);
  line-height: 1.6;
  max-width: 54ch;
}

/* ---------- Work ---------- */
.work-item + .work-item { margin-top: var(--s6); }
.work-frame {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  margin-bottom: var(--s3);
}
.work-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 700ms var(--ease), filter 700ms var(--ease), opacity 700ms var(--ease);
}

.work-title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(1.625rem, 4.5vw, 2.25rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-bottom: 10px;
}
.work-note { color: var(--ink-soft); max-width: var(--measure); margin-bottom: var(--s2); }
.work-meta {
  font-size: var(--fs-15);
  color: var(--muted);
  max-width: var(--measure);
  margin-bottom: var(--s2);
}
.work-meta code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}
.work-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: var(--fs-15);
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--seal);
  padding-bottom: 2px;
  transition: color 400ms var(--ease);
}
.work-link:hover, .work-link:focus-visible { color: var(--seal); }
.work-tag {
  display: inline-block;
  font-size: var(--fs-11);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--seal);
  margin-bottom: var(--s1);
}

/* ---------- Approach ---------- */
.approach-list { display: grid; gap: var(--s4); }
.approach-item .rule { margin-bottom: var(--s2); margin-right: clamp(24px, 8vw, 90px); }
.approach-item h3 {
  font-size: var(--fs-17);
  font-weight: 500;
  margin-bottom: 6px;
}
.approach-item p { font-size: var(--fs-15); color: var(--muted); max-width: 42ch; }

/* ---------- Contact ---------- */
.contact { background: var(--paper-2); }
.contact-mail {
  display: inline-block;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(1.25rem, 6vw, 3.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--seal);
  text-decoration: none;
  word-break: break-word;
  padding-block: 12px; /* holds the tap target over 44px at the clamp floor */
  border-bottom: 1px solid transparent;
  transition: border-color 700ms var(--ease);
}
.contact-mail:hover, .contact-mail:focus-visible { border-bottom-color: var(--seal); }
.contact-note { margin-top: var(--s3); color: var(--muted); font-size: var(--fs-15); max-width: 40ch; }

/* ---------- Footer ---------- */
.site-footer {
  padding-block: var(--s4);
  padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline); /* the one rule that spans the full width */
}
.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
}
.footer-text { font-size: var(--fs-13); color: var(--muted); }
.footer-mark { width: 22px; height: 22px; filter: invert(var(--enso-invert)); opacity: 0.7; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* The hidden pre-state is scoped to .js so that with scripting off — or if
     main.js fails to load — the page still renders complete. */
  .js .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 900ms var(--ease), transform 900ms var(--ease);
    transition-delay: calc(var(--i, 0) * 60ms);
  }
  .js .reveal.is-in { opacity: 1; transform: none; }

  .hero h1 .w {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1000ms var(--ease), transform 1000ms var(--ease);
    transition-delay: calc(var(--i, 0) * 70ms);
  }
  .hero h1.is-in .w { opacity: 1; transform: none; }

  /* Painted on, clockwise from the opening at the lower right. */
  .hero-enso-wrap.can-paint .hero-enso {
    -webkit-mask-image: conic-gradient(from 135deg, #000 var(--sweep), transparent 0);
    mask-image: conic-gradient(from 135deg, #000 var(--sweep), transparent 0);
    animation: paint 1800ms var(--ease) forwards;
  }
  @keyframes paint { from { --sweep: 0%; } to { --sweep: 100%; } }
}

@media (hover: hover) and (pointer: fine) {
  .service:hover { color: var(--ink); }
  .service:hover::after, .service:focus-within::after { transform: scaleX(1); }

  .work-frame img { filter: grayscale(1) contrast(0.92); opacity: 0.62; }
  .work-item:hover .work-frame img,
  .work-item:focus-within .work-frame img {
    filter: grayscale(0) contrast(1);
    opacity: 1;
    transform: scale(1.02);
  }
}

/* Touch: the portfolio is content, not an affordance — never leave it greyed. */
@media (hover: none) {
  .work-frame img { filter: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .work-frame img, .service, .service::after { transition: none; }
  .work-item:hover .work-frame img, .work-item:focus-within .work-frame img { transform: none; }
}

/* ---------- 640: large phone / small tablet ---------- */
@media (min-width: 640px) {
  :root { --gutter: 32px; --section-y: 120px; }
  .site-nav .nav-wide { display: inline-flex; }
  .site-nav { gap: var(--s3); }
  .hero h1 { line-height: 1.06; }
  .hero-enso-wrap { top: 50%; right: -12vw; width: 62vw; transform: translateY(-50%); }
  .hero-enso { opacity: calc(0.08 - var(--scroll, 0) * 0.04); }
  .approach-list { grid-template-columns: 1fr 1fr; gap: var(--s4) var(--s5); }
}

/* ---------- 900: tablet and up ---------- */
@media (min-width: 900px) {
  :root { --gutter: 48px; --section-y: var(--s7); }
  .hero h1 { line-height: 1.05; }
  .hero-enso-wrap { width: 46vw; }

  .service {
    display: grid;
    grid-template-columns: 56px 1fr 1fr;
    gap: var(--s3);
    align-items: baseline;
    padding-block: var(--s3);
  }
  .service-num { margin-bottom: 0; }
  .service-name { margin-bottom: 0; }

  .work-note { font-size: var(--fs-21); line-height: 1.5; }
  .contact-mail { word-break: normal; }
}

/* Scroll-linked rotation is decorative and the most expensive thing here on a
   phone GPU, so it only exists from 640 up. */
@media (min-width: 640px) and (prefers-reduced-motion: no-preference) {
  .hero-enso-wrap {
    transform: translateY(-50%) rotate(calc(var(--scroll, 0) * 6deg));
    will-change: transform;
  }
}
