/* 100 days, 100 portraits — the portrait viewer (/portraits/).
   One drawing large on the Sage wall, its label beside it (below on phones), F's ruler of all 100 days underneath.
   Builds on base.css tokens and the shared header/footer; nothing here restyles shared components. */

:root { --head-h: 66px; } /* real header height is measured by viewer.js */
body.page-portraits { background: var(--wall); }
html:not(.js) .needs-js { display: none !important; }
.viewer [hidden] { display: none !important; } /* .chip / video display rules would otherwise beat the hidden attribute */

.viewer {
  --vh: 100vh;
  /* The drawing and the ruler share the first view, no scrolling (Neli, 23 Oct 2026).
     --ruler-h is the ruler block's real height, measured by viewer.js; chrome = top padding 24 + gap above the ruler + 16 below */
  --ruler-h: 150px;
  --ruler-gap: 24px;
  --chrome: calc(24px + var(--ruler-gap) + var(--ruler-h) + 16px + var(--scrub-h, 40px));
  --frame-w: clamp(200px, calc((var(--vh) - var(--head-h) - var(--chrome)) * 9 / 16), 720px);
  --hair: rgba(37, 37, 37, .18);
  --chip-line: rgba(37, 37, 37, .4);
  display: block;
  padding: 24px var(--gutter) clamp(64px, 8vw, 104px);
  background: var(--wall);
  color: var(--on-wall);
  overflow-x: hidden;
}
@supports (height: 100svh) { .viewer { --vh: 100svh; } }
@supports (overflow: clip) { .viewer { overflow-x: clip; } }
.viewer a { color: var(--on-wall); text-decoration-color: rgba(138, 59, 44, .6); }
.viewer a:hover { color: var(--brass); text-decoration-color: currentColor; }
.viewer svg { flex: none; }
.kicker { margin: 0; font: 600 12px/16px var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--brass); }

/* ---------- The drawing ---------- */
.stage { display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 20px; }
.art { margin: 0; width: 100%; justify-self: center; scroll-margin-top: calc(var(--head-h) + 12px); }
.art__shade { display: block; filter: drop-shadow(0 5px 8px rgba(16, 18, 15, .2)); } /* one soft shadow; it follows the torn edge */
.art__sheet {
  position: relative; display: block; width: 100%; aspect-ratio: var(--ar, 9 / 16); overflow: hidden; /* --ar: the day's real shape (data.js SHAPES) */
  background: var(--ground); touch-action: pan-y; -webkit-tap-highlight-color: transparent;
}
.art__sheet .layer { position: absolute; top: 0; left: 0; width: 100%; opacity: 0; z-index: 1; transition: opacity .42s var(--ease); }
.art__sheet img.layer { height: auto; aspect-ratio: var(--ar, 9 / 16); } /* width + real shape + height auto: never stretched */
.art__sheet .layer.is-front { opacity: 1; z-index: 2; }
.art__sheet .layer.is-behind { opacity: 1; z-index: 1; transition: none; }
.art__sheet.is-cut .layer { transition: none; }
.art__sheet .art__film { height: 100%; object-fit: contain; background: var(--ground); z-index: 3; }
.art__sheet .art__film.is-on { opacity: 1; }
.art__sheet.is-film { cursor: pointer; }
/* The time-lapse bar under the drawing (Neli, 28 Oct 2026): play/pause, a thin line to scrub, the time.
   It hangs below the figure, so the drawing and the cards behind keep their place; --chrome makes room for it. */
.viewer { --scrub-h: 40px; }
.art { margin-bottom: var(--scrub-h); }
.scrub { position: absolute; left: 0; right: 0; top: 100%; height: var(--scrub-h); z-index: 2;
  display: flex; align-items: center; gap: 12px; padding-top: 8px;
  transition: opacity .5s cubic-bezier(.23, 1, .32, 1) .12s, visibility 0s .12s; }
/* It no longer pops in after a flick (Neli, 28 Oct 2026): it slips away while the drawings turn and fades back once landed */
.scrub[hidden] { display: flex !important; }
.scrub[hidden], .art.is-turning .scrub { opacity: 0; visibility: hidden; transition: opacity .12s, visibility 0s .12s; }
/* A label line, like a museum label, instead of a boxed button (Neli, 28 Oct 2026: the box popped) */
.scrub__play { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 34px; margin: 0; padding: 0;
  background: none; border: 0; color: var(--on-wall); font: inherit; font-size: 12px; letter-spacing: .02em; white-space: nowrap;
  cursor: pointer; transition: color .2s; }
.scrub__play:hover, .scrub__play:focus-visible { color: var(--brass); }
.scrub__play:focus-visible { outline: 1px solid var(--brass); outline-offset: 3px; }
.scrub__play svg { flex: none; width: 9px; height: 9px; }
.scrub__word { border-bottom: 1px solid var(--chip-line); padding-bottom: 1px; transition: border-color .2s; }
.scrub__play:hover .scrub__word { border-color: var(--brass); }
.scrub__play .i-pause, .scrub.is-playing .scrub__play .i-play { display: none; }
.scrub.is-playing .scrub__play .i-pause { display: block; }
.scrub__track { position: relative; flex: 1; height: 32px; cursor: pointer; touch-action: none; --p: 0; }
.scrub__line, .scrub__done { position: absolute; left: 0; top: 50%; height: 1px; transform: translateY(-50%); }
.scrub__line { right: 0; background: var(--chip-line); }
.scrub__done { width: calc(var(--p) * 100%); height: 2px; background: var(--brass); }
.scrub__knob { position: absolute; top: 50%; left: calc(var(--p) * 100%); width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50%; background: var(--brass); opacity: 0; transition: opacity .2s; }
.scrub.is-on .scrub__knob, .scrub__track:hover .scrub__knob, .scrub__track:focus-visible .scrub__knob { opacity: 1; }
.scrub__track:focus-visible { outline: 1px solid var(--brass); outline-offset: 2px; }
.scrub__time { flex: none; min-width: 34px; text-align: right; font-size: 12px; letter-spacing: .02em; color: var(--on-wall-2);
  font-variant-numeric: tabular-nums lining-nums; }
/* Drag the drawing sideways to change day (viewer.js) */
.art__sheet { cursor: grab; user-select: none; -webkit-user-select: none; }
.art__sheet img { -webkit-user-drag: none; }
.art__shade.is-dragging, .art__shade.is-dragging .art__sheet { cursor: grabbing; }
.art__shade.is-springing { transition: transform .3s cubic-bezier(.23, 1, .32, 1); }

/* Phones: drawing, then the ruler straight under it, then the label, so both fit the first view */
@media (max-width: 519.98px) {
  .viewer { display: flex; flex-direction: column; }
  .stage { display: contents; }
  /* Always as tall as a 9:16 drawing, so the ruler doesn't jump on the square and 3:4 colour days */
  /* a little smaller than the screen, so the cards behind show on both sides (each sticks out a fifth) */
  .viewer { --art-w: min(calc((100vw - 2 * var(--gutter)) / 1.45), var(--frame-w)); }
  .art { order: 1; width: var(--art-w); align-self: center;
    min-height: calc(var(--art-w) * 16 / 9); display: flex; flex-direction: column; justify-content: center; }
  .viewer .film-row[hidden] { display: flex !important; visibility: hidden; } /* keeps its room, so the day number doesn't jump */
  .ruler-block { order: 2; width: 100%; }
  .info { order: 3; margin-top: 36px; }
  .nearby { order: 4; }
}

/* ---------- The label beside the drawing ---------- */
.info { min-width: 0; }
.film-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 12px; min-height: 44px; }
.film-time { font-size: 13px; line-height: 1; letter-spacing: .02em; color: var(--on-wall-2); font-variant-numeric: tabular-nums lining-nums; }

.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 44px; min-height: 44px; margin: 0; padding: 0 15px;
  background: transparent; border: 1px solid var(--chip-line); border-radius: 0;
  color: var(--on-wall); font: 500 14px/1 var(--sans); letter-spacing: .01em; white-space: nowrap;
  font-variant-numeric: tabular-nums lining-nums; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.viewer .chip:hover { background: var(--on-wall); border-color: var(--on-wall); color: var(--ink); }
.chip:active { transform: translateY(1px); }
.chip[aria-disabled="true"], .viewer .chip[aria-disabled="true"]:hover { opacity: .4; cursor: default; background: transparent; border-color: var(--chip-line); color: var(--on-wall); transform: none; }
.chip--film .i-draw, .chip--film.is-on .i-film { display: none; }
.chip--film.is-on .i-draw { display: block; }
.chip--play .i-pause, .chip--play.is-playing .i-play { display: none; }
.chip--play.is-playing .i-pause { display: block; }
@media (hover: none) {
  .viewer .chip:hover { background: transparent; border-color: var(--chip-line); color: var(--on-wall); }
}

.label { margin-top: 28px; }
.daynum { margin: 0; font-weight: 400; }
.daynum:focus { outline: none; }
.daynum__n {
  display: block; margin-top: 8px;
  font: 400 clamp(96px, 28vw, 136px)/.84 var(--serif); letter-spacing: -.015em;
  font-variant-numeric: lining-nums tabular-nums; font-variation-settings: "opsz" 60; /* sturdier hairlines, easier to read */
}
.sitter { margin: 18px 0 0; font: 500 clamp(19px, 1.5vw, 22px)/1.35 var(--sans); overflow-wrap: anywhere; }
.sitter { min-height: calc(clamp(19px, 1.5vw, 22px) * 1.35); }
.sitter.is-long { font-size: 16px; }
/* The rotating cards: copies that fly over the page while the real ones swap (viewer.js turn()) */
.turn-card { position: fixed; z-index: 40; pointer-events: none; transform-origin: 0 0; filter: drop-shadow(0 5px 8px rgba(16, 18, 15, .2)); }
.turn-card__paper { width: 100%; height: 100%; background: var(--ground); }
.turn-card__paper { position: relative; }
.turn-card__paper img, .turn-card__paper canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.turn-card__wash { position: absolute; inset: 0; background: #FFFFFF; }
.art.is-turning .peek { pointer-events: none; }
.sitter .is-unnamed { color: var(--on-wall-2); }
.notes { margin: 14px 0 0; max-width: 32em; font-size: 16px; line-height: 1.55; }
.notes p { margin: 0 0 4px; }

/* From 520px: the drawing on the left, the label beside it (Neli, 23 Oct 2026); from 720px the carousel below takes over */
@media (min-width: 520px) {
  .stage { grid-template-columns: auto minmax(200px, 400px); justify-content: center; column-gap: clamp(32px, 5.5vw, 96px); }
  .viewer { --art-w: min(var(--frame-w), 50vw); }
  .art { width: var(--art-w); align-self: start;
    /* square and 3:4 days sit centred in the room a 9:16 drawing takes, so flicking between shapes doesn't jump (Neli, 27 Oct 2026) */
    min-height: calc(var(--art-w) * 16 / 9); display: flex; flex-direction: column; justify-content: center; }
  .info { display: flex; flex-direction: column; justify-content: space-between; }
  /* The day number and name stay still while scrubbing (Neli, 23 Oct 2026): the row is always as tall as a 9:16 drawing
     (the colour days are shorter), and the notes always keep room for three lines. */
  .info { min-height: calc(var(--art-w) * 16 / 9); }
  .notes { min-height: calc(3 * 1.55em + 12px); }
  .label { margin-top: 32px; }
  .daynum__n { font-size: clamp(72px, 10.5vw, 168px); }
}

/* ---------- The ruler: all 100 days (F's idea) ---------- */
.ruler-block { max-width: 1360px; margin: var(--ruler-gap) auto 0; }
.ruler-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 24px; margin-bottom: 10px; }
.ruler-head label { cursor: default; }

.ruler {
  --inset: 10px;
  position: relative; height: 76px;
  touch-action: pan-y; cursor: grab;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.ruler.is-dragging { cursor: grabbing; }
.ruler__annot, .ruler__scale { position: absolute; left: 0; right: 0; pointer-events: none; }
.ruler__annot { top: 0; height: 30px; }
.ruler__scale { top: 30px; height: 44px; }
/* A day's place on the ruler: --f = (day - 1) / 99, --w = a span in the same units */
.r-at { position: absolute; left: calc(var(--inset) + (100% - 2 * var(--inset)) * var(--f)); }
.r-span { width: calc((100% - 2 * var(--inset)) * var(--w)); }

.r-tick { top: calc(22px - var(--h, 6px)); width: 1px; height: var(--h, 6px); background: var(--on-wall-2); }
.r-tick--5 { --h: 10px; }
.r-tick--10 { --h: 16px; background: var(--on-wall); }
.r-base { position: absolute; top: 22px; left: var(--inset); right: var(--inset); height: 1px; background: var(--hair); }
.r-num { top: 27px; transform: translateX(-50%); font: 500 12px/14px var(--sans); color: var(--on-wall-2); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }

.r-label { top: 0; font: 500 12px/14px var(--sans); color: var(--on-wall-2); white-space: nowrap; }
.r-bracket { top: 19px; height: 7px; border: 1px solid var(--on-wall-2); border-bottom: 0; }
.r-film { top: 21px; width: 0; height: 0; margin-left: -4px; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 6px solid var(--on-wall-2); }
/* The annotation the current day belongs to turns pale brass */
.r-label.is-on { color: var(--brass); }
.r-bracket.is-on { border-color: var(--brass); }
.r-film.is-on { border-top-color: var(--brass); }

.ruler__input {
  position: absolute; left: 0; top: 14px; width: 100%; height: 60px; margin: 0;
  opacity: 0; pointer-events: none; -webkit-appearance: none; appearance: none; background: transparent;
} /* the real, labelled control for keyboards and screen readers; pointers drag the ruler itself */
.ruler__marker {
  position: absolute; top: 14px; width: 0; height: 58px; z-index: 3; pointer-events: none;
  left: calc(var(--inset) + (100% - 2 * var(--inset)) * var(--f, .5));
  transition: left .26s var(--ease);
}
.ruler.is-dragging .ruler__marker, .ruler.is-instant .ruler__marker { transition: none; }
.ruler__line { position: absolute; left: -1px; top: 0; width: 2px; height: 40px; background: var(--brass); }
.ruler__tab {
  position: absolute; left: 0; top: 40px; transform: translateX(-50%);
  padding: 2px 6px; background: var(--brass); color: var(--wall);
  font: 600 12px/14px var(--sans); letter-spacing: .06em; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap;
}
.ruler__input:focus-visible ~ .ruler__marker .ruler__tab { outline: 2px solid var(--on-wall); outline-offset: 2px; }

@media (max-width: 719.98px) {
  .ruler__tab { padding: 2px 4px; letter-spacing: .02em; } /* stays clear of the decade labels either side */
}

/* ---------- Neighbouring days ---------- */
.nearby { max-width: 1180px; margin: clamp(56px, 7vw, 88px) auto 0; }
.nearby .kicker { text-align: center; }
.strip {
  display: grid; grid-template-columns: repeat(var(--count, 11), minmax(0, 84px)); justify-content: center;
  gap: 0 clamp(12px, 1.8vw, 22px); margin: 22px 0 0; padding: 0; list-style: none;
}
.strip a { display: block; padding-top: 6px; text-decoration: none; }
.strip__shade { display: block; filter: drop-shadow(0 3px 4px rgba(16, 18, 15, .2)); transition: transform .3s var(--ease); }
.strip__sheet { display: block; background: var(--ground); }
.strip__tag { display: block; margin-top: 10px; font: 500 12px/14px var(--sans); letter-spacing: .14em; color: var(--brass); font-variant-numeric: tabular-nums lining-nums; }
.strip a:hover .strip__shade { transform: translateY(-3px); }
.strip a[aria-current] .strip__shade { transform: translateY(-6px); }
.strip a[aria-current] .strip__tag { color: var(--on-wall); text-decoration: underline; text-decoration-color: var(--brass); text-decoration-thickness: 2px; text-underline-offset: 5px; }

@media (forced-colors: active) {
  .r-tick, .r-base, .ruler__line { background: CanvasText; }
  .r-bracket { border-color: CanvasText; }
  .r-film { border-top-color: CanvasText; }
  .ruler__tab { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}

/* ---------- Carousel (Neli, 23 Oct 2026): the drawing in the middle of the page, the buttons and label in the right column,
   and the next day, smaller, tucked behind it on the left to show there is more ---------- */
.art { position: relative; }
.art__shade { position: relative; z-index: 1; }
/* At every width (Neli, 23 Oct 2026): on narrow screens the drawing is made smaller so both cards fit */
.peek {
  display: block; position: absolute; z-index: 0; top: 50%; right: 35%; width: 85%;
  transform: translateY(-50%); transition: transform .3s var(--ease);
}
.peek--next { right: auto; left: 35%; }
.peek__sheet { position: relative; }
/* Clicks and drags selected the card behind and the browser painted it solid blue (Neli saw it flicker blue on every turn) */
.peek, .peek *, .art, .art * { -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
.peek img::selection, .art img::selection { background: transparent; }
.peek__sheet::after { content: ""; position: absolute; inset: 0; z-index: 3; background: #FFFFFF; opacity: .45; pointer-events: none; transition: opacity .3s var(--ease); }
.peek:hover { transform: translate(-6px, -50%); }
.peek--next:hover { transform: translate(6px, -50%); }
.peek:hover .peek__sheet::after { opacity: .2; }
.peek__shade { display: block; filter: drop-shadow(0 4px 7px rgba(16, 18, 15, .2)); }
.peek__sheet { display: block; background: var(--ground); }
@media (min-width: 720px) {
  /* Centred when there is room; in narrower windows the left side shrinks, keeping just enough for the stack of cards */
  .viewer { --art-w: min(var(--frame-w), 36vw); }
  .stage { grid-template-columns: minmax(calc(var(--art-w) * .24), 1fr) auto minmax(calc(200px + var(--art-w) * .2), 1fr); justify-content: stretch; column-gap: clamp(24px, 4.5vw, 80px); }
  .art { grid-column: 2; }
  .info { grid-column: 3; max-width: 400px; }
  .daynum__n { font-size: clamp(80px, 8.5vw, 168px); }
  /* One card behind on each side (SLOTS in viewer.js), both at 85%: the day before on the left, its right edge 65% across
     the drawing; the next day on the right, its left edge 35% across. Solid, lightened with a white wash (Neli). */
  /* room on the right for the next card: it sticks out a fifth of the drawing */
  .info { margin-left: calc(var(--art-w) * .2); }
}

/* 520–719px: the drawing on the left, smaller, with room for the card behind on each side */
@media (min-width: 520px) and (max-width: 719.98px) {
  .viewer { --art-w: min(var(--frame-w), 32vw); }
  .art { margin-left: calc(var(--art-w) * .22); }
  .info { margin-left: calc(var(--art-w) * .2); }
  .viewer .film-row[hidden] { display: flex !important; visibility: hidden; } /* the label is taller than the drawing here: keep the button's room so the ruler holds still */
}

/* 520–899px: the label column is narrow, so keep room for five lines of notes and set long names smaller, so the number holds still */
@media (min-width: 520px) and (max-width: 899.98px) {
  .notes { min-height: calc(5 * 1.55em + 20px); }
  .label { margin-top: 16px; }
  .viewer .daynum__n { font-size: 68px; }
  .sitter.is-long { font-size: 14px; }
}
