/* ============================================================================
   Jenia Kris — Build B (dark scrolling gallery). Standalone stylesheet for
   www/final.html. Token-driven, layered, direction-agnostic. Self-hosted fonts
   (the production CSP blocks Google Fonts). Mood: dark.
   ========================================================================== */

/* ---- self-hosted fonts (WOFF2 in www/fonts/) ---------------------------- */
@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('fonts/cinzel-400-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Anton';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/anton-400-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('fonts/heebo-900-hebrew.woff2') format('woff2');
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Frank Ruhl Libre';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/frank-ruhl-libre-400-hebrew.woff2') format('woff2');
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Frank Ruhl Libre';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/frank-ruhl-libre-400-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Frank Ruhl Libre';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/frank-ruhl-libre-500-hebrew.woff2') format('woff2');
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Frank Ruhl Libre';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/frank-ruhl-libre-500-latin.woff2') format('woff2');
}

@layer reset, tokens, base, layout, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { min-block-size: 100svh; line-height: 1.5; -webkit-font-smoothing: antialiased; }
  img, picture, svg { display: block; max-inline-size: 100%; block-size: auto; }
  h1, h2, h3, p { overflow-wrap: break-word; text-wrap: pretty; }
  a { color: inherit; text-decoration: none; }
  :where(button) { font: inherit; color: inherit; background: none; border: 0; }
}

@layer tokens {
  :root {
    color-scheme: dark;
    /* Palette (dark mood) */
    --bg:        #15120f;
    --surface:   #1e1a15;
    --ink:       #f3ede3;
    --ink-muted: #b6ad9e;
    --line:      rgb(243 237 227 / 14%);
    --accent:    #d8a566;
    --field-tint: rgb(13 10 7 / 46%);   /* over each blurred field, for legibility */

    /* Text set over imagery (hero, captions): cream tints that stay legible */
    --ink-on:      #f3ede3;
    --ink-on-soft: #e7ddca;
    --ink-on-dim:  #d9d0c0;
    --scrim:       rgb(8 6 4 / 58%);

    /* Type (self-hosted) */
    --font-display: "Frank Ruhl Libre", Georgia, serif;
    --font-body:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-hebrew:  "Frank Ruhl Libre", Georgia, serif;
    --font-latin:   "Cinzel", Georgia, serif;   /* English display */

    --text-sm:    clamp(0.83rem, 0.80rem + 0.15vw, 0.92rem);
    --text-base:  clamp(1.00rem, 0.95rem + 0.25vw, 1.13rem);
    --text-lg:    clamp(1.20rem, 1.10rem + 0.50vw, 1.50rem);
    --display-sm: clamp(2.00rem, 1.55rem + 2.20vw, 3.40rem);
    --display:    clamp(3.00rem, 2.10rem + 4.50vw, 6.50rem);

    --space-xs:  clamp(0.75rem, 0.70rem + 0.25vw, 1.00rem);
    --space-sm:  clamp(1.00rem, 0.90rem + 0.50vw, 1.50rem);
    --space-md:  clamp(1.50rem, 1.30rem + 1.00vw, 2.50rem);
    --space-lg:  clamp(2.50rem, 2.00rem + 2.50vw, 5.00rem);

    --container: 76rem;
    --gutter:    clamp(1.25rem, 5vw, 4rem);
    --radius:    2px;
    --work-scroll: 135vh;   /* per-work scroll length; > 100svh so the art pins, tuned to keep the hold without dead space */
    --header-h:  3.5rem;    /* approx fixed-header height; portrait art pins below it */

    --ease: cubic-bezier(0.22, 1, 0.30, 1);
    --dur:  640ms;
  }
}

@layer base {
  body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: var(--text-base); }
  h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.0; }
  :lang(he) { font-family: var(--font-hebrew); }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius); }
  ::selection { background: var(--ink); color: var(--bg); }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  }
  @media (forced-colors: active) { .work__art img, .hero__panel { border: 1px solid CanvasText; } }
}

@layer layout {
  .wrap { inline-size: min(100% - var(--gutter) * 2, var(--container)); margin-inline: auto; }
  .site-header { position: fixed; inset-block-start: 0; inset-inline: 0; z-index: 50; padding: var(--space-sm) var(--gutter); display: flex; justify-content: space-between; align-items: baseline; color: var(--ink-on); }
  /* A soft top scrim keeps the chrome legible over any painting. Replaces the
     old mix-blend-mode: difference wordmark, which washed out over light art. */
  .site-header::before { content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; block-size: 220%; background: linear-gradient(to bottom, rgb(8 6 4 / 50%), rgb(8 6 4 / 0%)); z-index: -1; pointer-events: none; }
  .site-footer { position: relative; min-block-size: 100svh; display: grid; place-content: center; justify-items: center; gap: var(--space-lg); padding: var(--space-lg) var(--gutter); text-align: center; overflow: clip; }
}

@layer components {
  .skip-link { position: absolute; inset-block-start: var(--space-xs); inset-inline-start: var(--space-xs); z-index: 100; padding: var(--space-xs) var(--space-sm); background: var(--ink); color: var(--bg); border-radius: var(--radius); transform: translateY(-150%); transition: transform var(--dur) var(--ease); }
  .skip-link:focus { transform: none; }

  .wordmark { font-family: var(--font-latin); font-size: var(--text-lg); display: flex; gap: 0.6ch; align-items: baseline; text-shadow: 0 1px 10px rgb(0 0 0 / 45%); }
  .wordmark__sep { opacity: 0.6; }
  /* the menu glyph + pointer appear only once app.js enhances the wordmark to a button */
  .wordmark[aria-expanded] { cursor: pointer; }
  .wordmark__menu { display: none; }
  .wordmark[aria-expanded] .wordmark__menu { display: inline-flex; align-self: center; margin-inline-end: 0.1ch; }
  .wordmark__menu svg { display: block; }

  /* ---------------------------------------------------------------- HERO -- */
  /* Three full-height panels filling the screen; the title over a scrim.
     The panels show 3 random works and crossfade one at a time (see app.js);
     static 3-image fallback in the markup for no-JS. */
  .hero { position: relative; block-size: 100svh; overflow: clip; }
  .hero__panels { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .hero__panel { position: relative; overflow: clip; background: var(--surface); }
  .hero__img { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; object-fit: cover; transition: opacity 2.4s var(--ease), transform 3s var(--ease); }
  .hero__img.is-entering { opacity: 0; transform: scale(1.06); }
  .hero__scrim { position: absolute; inset: 0; background: radial-gradient(ellipse 80% 64% at 50% 50%, var(--scrim), rgb(8 6 4 / 14%) 72%); }
  .hero__intro { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; justify-items: center; text-align: center; padding: var(--gutter); color: var(--ink-on); text-shadow: 0 1px 2px rgb(0 0 0 / 62%), 0 2px 26px rgb(0 0 0 / 48%); }
  .hero__title { display: grid; gap: 0.1em; justify-items: center; }
  .hero__title [lang=he] { font-size: var(--display); font-weight: 500; }
  .hero__title-en { font-family: var(--font-latin); font-size: var(--text-lg); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-on-soft); }
  .hero__tagline { max-inline-size: 42ch; margin-inline: auto; margin-block-start: var(--space-sm); color: var(--ink-on-soft); }
  .hero__cue { margin-block-start: var(--space-md); color: var(--ink-on-soft); opacity: 0.85; }
  .hero__cue svg { display: block; margin-inline: auto; }

  /* ------------------------------------------------------------- GALLERY -- */
  /* Each work: a full-bleed field blurred from its own painting, the whole
     painting pinned over it (art-weighted), and the bilingual caption scrolling
     past in the narrower column. Sides alternate. */
  .work { display: grid; grid-template-columns: 1.85fr 1.15fr; align-items: start; position: relative; }
  .work:nth-of-type(even) { grid-template-columns: 1.15fr 1.85fr; }

  /* field covers the whole section so work-to-work hands off colour-to-colour (no dark gap) */
  .work__field { position: absolute; inset: 0; overflow: clip; z-index: 0; }
  .work__field img { inline-size: 100%; block-size: 100%; object-fit: cover; transform: scale(1.12); filter: blur(46px) saturate(1.35) brightness(0.92); }
  .work__field::after { content: ""; position: absolute; inset: 0; background: var(--field-tint); }

  .work__art { grid-row: 1; grid-column: 1; position: sticky; inset-block-start: 0; block-size: 100svh; z-index: 1; display: grid; place-items: center; padding: var(--space-lg) var(--gutter); }
  .work:nth-of-type(even) .work__art { grid-column: 2; }
  .work__art img { max-block-size: 80svh; max-inline-size: 100%; inline-size: auto; box-shadow: 0 2rem 5rem -1.5rem rgb(0 0 0 / 60%); }

  .work__text { grid-row: 1; grid-column: 2; z-index: 1; min-block-size: var(--work-scroll); display: grid; align-content: center; justify-items: start; gap: var(--space-sm); padding: var(--space-lg) var(--gutter); color: var(--ink-on); text-shadow: 0 1px 18px rgb(0 0 0 / 55%); }
  .work:nth-of-type(even) .work__text { grid-column: 1; }
  .work__index { font-family: var(--font-display); letter-spacing: 0.25em; color: var(--accent); }
  .work__title { display: grid; gap: 0.15em; justify-items: start; }
  .work__title [lang=he] { font-size: var(--display-sm); font-weight: 500; }
  .work__title-en { font-family: var(--font-latin); font-size: var(--text-base); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-on-soft); }
  .work__meta { display: grid; gap: 0.1em; font-size: var(--text-sm); color: var(--ink-on-dim); }
  .work__meta [lang=he] { font-size: var(--text-base); }

  /* ------------------------------------------------------------- FOOTER -- */
  /* Closing panel: a blurred painting field (random, crossfading + a slow drift)
     fills the panel; the name sits large and legible on top. Same field
     treatment as the gallery works, so the last work hands off into it. */
  .footer-field { position: absolute; inset: 0; z-index: 0; overflow: clip; }
  .footer-field__img { position: absolute; inset: 0; background-image: url(images/23.jpg); background-size: cover; background-position: center; transform: scale(1.12); filter: blur(46px) saturate(1.35) brightness(0.95); transition: opacity 2.4s var(--ease); animation: foot-drift 30s var(--ease) infinite alternate; }
  .footer-field__img.is-hidden { opacity: 0; }
  .footer-field::after { content: ""; position: absolute; inset: 0; background: rgb(13 10 7 / 38%); }
  @keyframes foot-drift { from { transform: scale(1.12); } to { transform: scale(1.26) translate3d(-1.5%, -1.5%, 0); } }

  .bigfoot { position: relative; z-index: 1; display: grid; justify-items: center; gap: 0.04em; color: var(--ink-on); text-shadow: 0 2px 34px rgb(0 0 0 / 55%), 0 1px 3px rgb(0 0 0 / 45%); }
  /* name sized by the smaller of width/height so it fits one screen (and one line) at any orientation */
  .bigfoot__he { font-family: "Heebo", system-ui, sans-serif; font-weight: 900; font-size: clamp(2.4rem, min(17vw, 28vh), 15.5rem); line-height: 1.08; }
  .bigfoot__en { font-family: "Anton", system-ui, sans-serif; font-weight: 400; font-size: clamp(1.5rem, min(7.5vw, 11vh), 5.5rem); line-height: 1.28; letter-spacing: 0.05em; text-transform: uppercase; padding-block-end: 0.08em; }
  .bigfoot__meta { position: relative; z-index: 1; color: var(--ink-on-soft); text-shadow: 0 1px 12px rgb(0 0 0 / 55%); font-size: var(--text-sm); display: flex; flex-wrap: wrap; gap: 0.6ch 1.4ch; justify-content: center; align-items: baseline; }
  .bigfoot__meta a { border-block-end: 1px solid currentColor; }

  /* ------------------------------------------------------------ NOT FOUND -- */
  .notfound { min-block-size: 100svh; display: grid; place-content: center; justify-items: center; gap: var(--space-sm); text-align: center; padding: var(--gutter); }
  .notfound__code { font-family: var(--font-latin); font-size: var(--display-sm); letter-spacing: 0.3em; color: var(--accent); }
  .notfound__title { font-size: var(--display-sm); }
  .notfound__sub { color: var(--ink-muted); }
  .notfound__home { margin-block-start: var(--space-sm); color: var(--ink-on-soft); border-block-end: 1px solid currentColor; }

  /* ---------------------------------------------------------- WORK INDEX -- */
  /* A toggle drawer to jump to any painting. The wordmark opens it (see app.js);
     the panel slides in from the inline-start over a backdrop. */
  .work-index { position: fixed; inset: 0; z-index: 60; }
  .work-index[hidden] { display: none; }   /* author position:fixed would beat the UA hidden style */
  .work-index__backdrop { position: absolute; inset: 0; background: rgb(8 6 4 / 62%); opacity: 0; transition: opacity var(--dur) var(--ease); }
  .work-index.is-open .work-index__backdrop { opacity: 1; }

  .work-index__panel { position: absolute; z-index: 1; inset-block: 0; inset-inline-start: 0; inline-size: min(86vw, 23rem); display: flex; flex-direction: column; background: var(--surface); box-shadow: 0 0 4rem rgb(0 0 0 / 55%); transform: translateX(-100%); transition: transform var(--dur) var(--ease); overflow-y: auto; overscroll-behavior: contain; }
  .work-index.is-open .work-index__panel { transform: none; }

  .work-index__head { position: sticky; inset-block-start: 0; display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-md) var(--space-md) var(--space-sm); background: var(--surface); }
  .work-index__title { font-family: var(--font-latin); font-size: var(--text-sm); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-muted); }
  .work-index__close { inline-size: 2.5rem; block-size: 2.5rem; display: grid; place-items: center; color: var(--ink); border-radius: var(--radius); }

  .work-index__list { list-style: none; padding: 0 var(--space-sm) var(--space-lg); display: grid; gap: 2px; }
  .work-index__item { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-xs) var(--space-sm); border-radius: var(--radius); transition: background var(--dur) var(--ease); }
  .work-index__item:hover { background: rgb(243 237 227 / 7%); }
  .work-index__item[aria-current="true"] { background: rgb(216 165 102 / 16%); }
  .work-index__thumb { flex: 0 0 auto; inline-size: 64px; block-size: 46px; object-fit: cover; border-radius: var(--radius); }
  .work-index__num { flex: 0 0 auto; font-family: var(--font-display); font-size: var(--text-sm); letter-spacing: 0.15em; color: var(--accent); }
  .work-index__labels { display: grid; gap: 0.1em; min-inline-size: 0; text-align: left; }
  .work-index__labels [lang="he"] { font-size: var(--text-base); line-height: 1.15; overflow-wrap: break-word; }
  .work-index__en { font-family: var(--font-latin); font-size: var(--text-sm); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }

  /* gentle reveal for the intro + captions */
  @media (prefers-reduced-motion: no-preference) {
    /* hero on-load entrance: panels wipe up (staggered), intro rises in */
    @keyframes panel-rise { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
    @keyframes h-rise { from { opacity: 0; transform: translateY(2.5rem); } to { opacity: 1; transform: none; } }
    .hero__panel { animation: panel-rise 1.3s var(--ease) both; }
    .hero__panel:nth-child(2) { animation-delay: 0.14s; }
    .hero__panel:nth-child(3) { animation-delay: 0.28s; }
    .hero__intro > * { animation: h-rise 1s var(--ease) both; }
    .hero__title { animation-delay: 0.5s; }
    .hero__tagline { animation-delay: 0.72s; }
    .hero__cue { animation-delay: 0.92s; }
    @keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }
    .hero__cue svg { animation: bob 1.8s ease-in-out 1.6s infinite; }

    /* gallery reveal on scroll: painting wipes in, caption rises */
    @supports (animation-timeline: view()) {
      .work__art img { animation: wipe linear both; animation-timeline: view(); animation-range: entry 4% entry 62%; }
      @keyframes wipe { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
      .work__text { animation: rise linear both; animation-timeline: view(); animation-range: entry 8% cover 26%; }
      @keyframes rise { from { opacity: 0; transform: translateY(2rem); } to { opacity: 1; transform: none; } }
    }
  }

  /* ----- portrait phones: held image + rising caption -----
     Single column. The painting pins below the header (row 1); the caption
     (row 2) scrolls up over it, then the section releases to the next work. */
  @media (max-width: 760px) and (orientation: portrait) {
    .work, .work:nth-of-type(even) { grid-template-columns: 1fr; }
    .work__field { grid-column: 1; }
    /* Art pins tall with the image at its TOP, leaving a field-gap beneath it.
       The caption rises through that gap up to the image, then the section
       releases to the next work -- so the caption never climbs over the art. */
    .work__art, .work:nth-of-type(even) .work__art { grid-row: 1; grid-column: 1; position: sticky; inset-block-start: var(--header-h); block-size: 76svh; place-items: start center; padding-block: var(--space-sm) 0; }
    .work__art img { max-block-size: 44svh; }
    .work__text, .work:nth-of-type(even) .work__text { grid-row: 2; grid-column: 1; min-block-size: 26vh; align-content: start; }
  }

  /* ----- landscape phones (short viewport): keep side-by-side so the wide,
     short screen shows the painting big; the art still pins beside the text. */
  @media (orientation: landscape) and (max-height: 560px) {
    .work__art { padding: var(--space-sm) var(--gutter); }
    .work__art img { max-block-size: 88svh; }
    .work__text { min-block-size: 120vh; }
    .site-footer { padding-block: var(--space-md); gap: var(--space-md); }
  }
}

@layer utilities {
  .visually-hidden { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
}
