/* Oaken Portfolio — client-facing styles
   Brand: Oaken Green #0E351F, Oaken Gold #AE976F, Century Gothic */
:root {
  --green: #0e351f;        /* Oaken Green — the page */
  --green-deep: #082314;   /* viewer backdrop */
  --green-raise: #164229;  /* image placeholders, inputs */
  --gold: #ae976f;         /* Oaken Gold — logo, focus, active states */
  --gold-60: #cec1a9;      /* 60% gold tint — hover on gold */
  --ivory: #f3eee4;        /* primary text */
  --mute: #9ca899;         /* secondary text */
  --line: rgba(174, 151, 111, .32);
  --font: "Century Gothic", CenturyGothic, "Didact Gothic", AppleGothic, "Avenir Next", sans-serif;
  --serif: var(--font);    /* kept for admin.css */
  --pad: clamp(20px, 5vw, 72px);
  --gap: clamp(12px, 1.6vw, 22px);
  --row: 260px;
  /* legacy aliases used by admin.css */
  --bg: var(--green); --raise: var(--green-raise); --ink: var(--ivory); --accent: var(--gold); --viewer: var(--green-deep);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--green); color: var(--ivory);
  font: 400 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
img, video { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
::selection { background: var(--gold); color: var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--mute); }
.text-link { color: var(--gold); }

/* Wordmark (inline SVG, coloured via `color`) */
.logo { display: block; width: 100%; height: auto; fill: currentColor; }
.brand { display: inline-block; color: var(--gold); width: clamp(118px, 13vw, 168px); line-height: 0; transition: color .3s ease; }
.brand:hover { color: var(--gold-60); }

/* ---------- Masthead ---------- */
.masthead { padding: clamp(28px, 4vw, 48px) var(--pad) clamp(28px, 4vw, 48px); max-width: 1600px; margin: 0 auto; }
.headline {
  font: 400 clamp(2.9rem, 9.5vw, 8.25rem)/0.98 var(--font);
  letter-spacing: -0.035em; margin: clamp(56px, 10vw, 150px) 0 0; max-width: 12ch;
  overflow-wrap: anywhere;
}
.intro { margin: clamp(18px, 2.4vw, 30px) 0 0; max-width: 48ch; color: var(--mute); font-size: 1.0625rem; }

@media (prefers-reduced-motion: no-preference) {
  .masthead .brand { animation: fade 1.2s ease both; }
  .headline { animation: rise 1.1s .25s cubic-bezier(.2,.7,.1,1) both; }
  .intro { animation: fade .9s .7s ease both; }
  .projects, .filters { animation: fade .9s .85s ease both; }
}
@keyframes rise { from { transform: translateY(0.3em); opacity: 0; clip-path: inset(0 0 100% 0); } to { transform: none; opacity: 1; clip-path: inset(0 0 -20% 0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px 28px; padding: 0 var(--pad) clamp(28px, 4vw, 44px); max-width: 1600px; margin: 0 auto; }
.filter {
  background: none; border: 0; padding: 4px 0; cursor: pointer; color: var(--mute);
  border-bottom: 1px solid transparent; font-size: 0.975rem;
}
.filter:hover { color: var(--ivory); }
.filter.is-on { color: var(--ivory); border-bottom-color: var(--gold); }

/* ---------- Project index: alternating 7/5 rows with matched heights ---------- */
.projects {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: clamp(40px, 5vw, 76px) var(--gap);
  padding: 0 var(--pad) clamp(60px, 8vw, 120px); max-width: 1600px; margin: 0 auto;
}
.card { grid-column: span 12; text-decoration: none; display: block; }
.card[hidden] { display: none; }
.card-media { margin: 0; background: var(--green-raise); aspect-ratio: 4 / 3; overflow: hidden; }
.card-media img, .card-media video { width: 100%; height: 100%; object-fit: cover; transition: transform 1s cubic-bezier(.2,.7,.1,1); }
.card:hover .card-media img, .card:hover .card-media video { transform: scale(1.025); }
.card-text { padding-top: 18px; display: grid; grid-template-columns: 1fr auto; column-gap: 20px; align-items: baseline; }
.card-title { font: 400 clamp(1.35rem, 2vw, 1.85rem)/1.2 var(--font); letter-spacing: -0.01em; margin: 0; grid-column: 1; transition: color .3s ease; }
.card:hover .card-title { color: var(--gold-60); }
.card-meta { margin: 6px 0 0; color: var(--mute); grid-column: 1; }
.card-count { margin: 0; color: var(--gold); font-size: .9rem; grid-column: 2; grid-row: 1; white-space: nowrap; }

@media (min-width: 820px) {
  .card:nth-child(4n+1), .card:nth-child(4n+4) { grid-column: span 7; }
  .card:nth-child(4n+2), .card:nth-child(4n+3) { grid-column: span 5; }
  .card:nth-child(4n+1) .card-media, .card:nth-child(4n+4) .card-media { aspect-ratio: 3 / 2; }
  .card:nth-child(4n+2) .card-media, .card:nth-child(4n+3) .card-media { aspect-ratio: 15 / 14; }
}
.empty { grid-column: span 12; color: var(--mute); }
@media (max-width: 600px) {
  .card-text { grid-template-columns: 1fr; }
  .card-count { grid-column: 1; grid-row: auto; margin-top: 2px; }
}

/* ---------- Project page ---------- */
.preview-bar { background: var(--gold); color: var(--green); text-align: center; padding: 10px var(--pad); font-size: .95rem; }
.project-head { padding: clamp(28px, 4vw, 48px) var(--pad) clamp(36px, 5vw, 64px); max-width: 1600px; margin: 0 auto; }
.project-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: clamp(48px, 8vw, 112px); }
.back { color: var(--mute); text-decoration: none; padding: 6px 0; }
.back::before { content: ""; display: inline-block; width: 18px; height: 1px; background: var(--gold); vertical-align: middle; margin-right: 12px; transition: width .3s ease; }
.back:hover { color: var(--ivory); }
.back:hover::before { width: 30px; }
.project-title { font: 400 clamp(2.4rem, 7vw, 6rem)/1 var(--font); letter-spacing: -0.03em; margin: 0; max-width: 18ch; overflow-wrap: anywhere; }
.project-meta { display: flex; flex-wrap: wrap; gap: 4px 28px; margin: 22px 0 0; color: var(--gold); }
.project-desc { margin-top: 26px; max-width: 60ch; font-size: 1.0625rem; line-height: 1.75; color: var(--ivory); }

/* Justified rows: each tile grows in proportion to its aspect ratio */
.justified { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 var(--pad); max-width: 1800px; margin: 0 auto; }
.justified::after { content: ""; flex: 999 1 calc(var(--row) * 2); }
.tile { position: relative; padding: 0; margin: 0; border: 0; background: var(--green-raise); cursor: zoom-in; min-width: 0; max-height: calc(var(--row) * 1.8); overflow: hidden; }
.tile-box { display: block; position: relative; }
.tile img, .tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .3s ease; }
.tile:hover img, .tile:hover video { opacity: .85; }
.play {
  position: absolute; left: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(8, 35, 20, .78); color: var(--ivory); padding: 6px 11px 6px 8px; border-radius: 999px;
  border: 1px solid var(--line);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); font-size: .85rem;
}
.play svg { color: var(--gold); }
.play em { font-style: normal; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { :root { --row: 150px; } .justified { gap: 4px; padding: 0 10px; } }
@media (min-width: 1500px) { :root { --row: 320px; } }

/* Next project */
.next { max-width: 1600px; margin: clamp(80px, 12vw, 160px) auto 0; padding: 0 var(--pad); }
.next a { display: grid; grid-template-columns: 1fr auto; gap: 8px 32px; align-items: end; text-decoration: none; border-top: 1px solid var(--line); padding-top: 28px; }
.next-label { color: var(--gold); grid-column: 1; }
.next-title { font: 400 clamp(1.9rem, 5vw, 4.2rem)/1.05 var(--font); letter-spacing: -0.025em; grid-column: 1; transition: color .3s ease; }
.next a:hover .next-title { color: var(--gold-60); }
.next img { grid-column: 2; grid-row: 1 / span 2; width: clamp(110px, 18vw, 260px); aspect-ratio: 4 / 3; object-fit: cover; }

/* Footer */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding: clamp(48px, 7vw, 96px) var(--pad) 40px; max-width: 1600px; margin: 0 auto; color: var(--mute); font-size: .95rem; }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--ivory); }
.foot-brand { color: var(--gold); width: 92px; line-height: 0; }
.foot-brand:hover { color: var(--gold-60) !important; }

/* ---------- Viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 50; background: var(--green-deep); display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.viewer[hidden] { display: none; }
.viewer-stage { position: absolute; inset: 56px 72px; display: flex; align-items: center; justify-content: center; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.viewer-stage video { background: #000; }
.viewer-stage .loading { width: 28px; height: 28px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; position: absolute; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: no-preference) {
  .viewer:not([hidden]) { animation: fade .25s ease; }
  .viewer-stage > * { animation: fade .3s ease; }
}
.v-btn { position: absolute; background: none; border: 0; padding: 12px; cursor: pointer; color: var(--ivory); opacity: .75; }
.v-btn:hover { opacity: 1; color: var(--gold-60); }
.v-close { top: max(8px, env(safe-area-inset-top)); right: 8px; }
.v-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.v-next { right: 8px; top: 50%; transform: translateY(-50%); }
.v-count { position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); margin: 0; text-align: center; color: var(--gold); font-size: .9rem; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .viewer-stage { inset: 52px 0 48px; }
  .v-prev, .v-next { top: auto; bottom: max(2px, env(safe-area-inset-bottom)); transform: none; }
}

/* ---------- Passcode / sign-in / not found ---------- */
body.gate { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-box { width: 100%; max-width: 380px; }
.gate-logo { display: block; width: 168px; height: auto; color: var(--gold); fill: currentColor; margin-bottom: 36px; }
.gate-title { font: 400 1.6rem/1.2 var(--font); margin: 0 0 10px; }
.gate-box form { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.gate-box input {
  background: var(--green-raise); border: 1px solid var(--line); color: var(--ivory); padding: 14px 16px;
  font: inherit; border-radius: 2px;
}
.gate-box input::placeholder { color: var(--mute); }
.gate-box input:focus { border-color: var(--gold); outline: none; }
.gate-box button { background: var(--gold); color: var(--green); border: 0; padding: 14px 16px; border-radius: 2px; cursor: pointer; letter-spacing: .01em; }
.gate-box button:hover { background: var(--gold-60); }
.gate-error { color: #e8b4a4; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
