/*
 * aintkaran - portfolio landing page
 * Flexoki. Image-first. All information in the corners.
 * Fonts: css/fonts.css. Captions: css/caption.css.
 */

/* Flexoki, trimmed to the steps this page actually uses (MIT,
   stephango.com/flexoki). Light = paper/black with 600 accents, dark =
   black/base-200 with 400 accents, per the Flexoki spec. Follows the
   system setting; no script, so no flash. Links use Flexoki blue (bl).
   Photos are never tinted. Reinstate a step from the full library if a
   future style needs it. */
:root {
  color-scheme: light dark;

  /* Base */
  --flexoki-black: #100F0F;
  --flexoki-base-950: #1C1B1A;
  --flexoki-base-900: #282726;
  --flexoki-base-850: #343331;
  --flexoki-base-800: #403E3C;
  --flexoki-base-700: #575653;
  --flexoki-base-600: #6F6E69;
  --flexoki-base-500: #878580;
  --flexoki-base-300: #B7B5AC;
  --flexoki-base-200: #CECDC3;
  --flexoki-base-150: #DAD8CE;
  --flexoki-base-100: #E6E4D9;
  --flexoki-base-50: #F2F0E5;
  --flexoki-paper: #FFFCF0;

  /* Accents: only the two steps the light/dark theme mapping uses */
  --flexoki-red-400: #D14D41;
  --flexoki-red-600: #AF3029;
  --flexoki-orange-400: #DA702C;
  --flexoki-orange-600: #BC5215;
  --flexoki-yellow-400: #D0A215;
  --flexoki-yellow-600: #AD8301;
  --flexoki-green-400: #879A39;
  --flexoki-green-600: #66800B;
  --flexoki-cyan-400: #3AA99F;
  --flexoki-cyan-600: #24837B;
  --flexoki-blue-400: #4385BE;
  --flexoki-blue-600: #205EA6;
  --flexoki-purple-400: #8B7EC8;
  --flexoki-purple-600: #5E409D;
  --flexoki-magenta-400: #CE5D97;
  --flexoki-magenta-600: #A02F6F;

  /* Theme mapping (Flexoki spec): bg surfaces, ui borders/hover, tx text */
  --bg: var(--flexoki-paper);
  --bg-2: var(--flexoki-base-50);
  --ui: var(--flexoki-base-100);
  --ui-2: var(--flexoki-base-150);
  --ui-3: var(--flexoki-base-200);
  --tx-3: var(--flexoki-base-300);
  --tx-2: var(--flexoki-base-600);
  --tx: var(--flexoki-black);

  /* Accents for this theme */
  --re: var(--flexoki-red-600);
  --or: var(--flexoki-orange-600);
  --ye: var(--flexoki-yellow-600);
  --gr: var(--flexoki-green-600);
  --cy: var(--flexoki-cyan-600);
  --bl: var(--flexoki-blue-600);
  --pu: var(--flexoki-purple-600);
  --ma: var(--flexoki-magenta-600);

  --font-body: 'TikTok Sans', Arial, Helvetica, sans-serif;
  --font-mono: 'TikTok Sans', 'Courier New', monospace;
  --pad: clamp(16px, 3vw, 40px);
  --img-h: min(52vh, 540px);
  --img-w: min(52vw, 780px); /* centre image leaves room for the scaled-down neighbours */
  --gap: clamp(72px, 10vw, 160px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--flexoki-black);
    --bg-2: var(--flexoki-base-950);
    --ui: var(--flexoki-base-900);
    --ui-2: var(--flexoki-base-850);
    --ui-3: var(--flexoki-base-800);
    --tx-3: var(--flexoki-base-700);
    --tx-2: var(--flexoki-base-500);
    --tx: var(--flexoki-base-200);

    --re: var(--flexoki-red-400);
    --or: var(--flexoki-orange-400);
    --ye: var(--flexoki-yellow-400);
    --gr: var(--flexoki-green-400);
    --cy: var(--flexoki-cyan-400);
    --bl: var(--flexoki-blue-400);
    --pu: var(--flexoki-purple-400);
    --ma: var(--flexoki-magenta-400);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--tx);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 300;
  font-optical-sizing: auto;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  /* Vertical touch stays native: pull-to-refresh and rubber-banding keep
     working. gallery.js owns only horizontal drags. pinch-zoom keeps
     two-finger page zoom working where supported; older engines ignore
     that value and fall back to plain pan-y. */
  touch-action: pan-y;
  touch-action: pan-y pinch-zoom;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--bl); text-decoration: underline; }
a:focus-visible, button:focus-visible {
  outline: 1px solid var(--tx);
  outline-offset: 3px;
}

/* ---- Corners: fixed, small type, generous padding ---- */
.corner {
  position: fixed;
  z-index: 10;
  padding: var(--pad);
  pointer-events: none;
}
/* Let only the visible text receive input. Corner padding stays transparent
   to the gallery; text can be selected and links keep their native cue. */
.corner .site-title, .corner .bio {
  pointer-events: auto;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
}
.corner a { pointer-events: auto; cursor: pointer; }
.corner-tl { top: 0; left: 0; }
.corner-tr {
  top: 0; right: 0; text-align: right;
  /* Desktop: the bio's first line sits level with the site name. The column
     gets a generous 72ch on wide screens (user's choice) and narrows as the
     window shrinks, never crossing the site name. On small screens it drops
     to its own full-width line (see the mobile block below). */
  max-width: min(72ch, calc(100vw - 2 * var(--pad) - 110px));
}

/* One text size and weight for the whole page: every element, corners to
   captions to footer, is 12px / weight 300. The top corners share a
   line-height, so their first baselines align. */
.site-title { font-size: 12px; font-weight: 300; letter-spacing: 0.01em; line-height: 19px; }
.bio { line-height: 19px; color: var(--tx-2); }
@media (min-width: 641px) {
  /* Desktop: compose the bio's line breaks deliberately - balanced line
     lengths, no orphan lines - instead of arbitrary wrapping. The bio
     link's own nowrap rule still keeps "Vitamin Studios" on one line.
     Browsers without text-wrap: balance fall back to plain wrapping. */
  .bio { text-wrap: balance; }
}
.bio a { text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; /* "Vitamin Studios" never splits across lines (user's rule, every viewport) */ }

/* ---- Gallery: the hero. Images own the middle of the screen. ---- */
.stage { height: 100vh; height: 100dvh; display: flex; align-items: center; position: relative; }

.viewport {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
  touch-action: pan-y; /* only horizontal touch drags are handled in
                          gallery.js; vertical stays native for pull-to-refresh */
  touch-action: pan-y pinch-zoom; /* ignored where unsupported; pan-y then applies */
  outline: none; /* Keep the gallery borderless for all input methods.
                    Keyboard arrows, zoom and the skip link still work. */
}
.viewport::-webkit-scrollbar { display: none; }
.viewport.drag { cursor: grabbing; }

.track {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0; /* the loop's cloned copies let every image centre, no end padding needed */
  min-width: max-content;
}

.track figure {
  flex: 0 0 auto;
  text-align: center;
  /* transform-origin is set per frame in JS: toward the edge nearest the
     centre image, so scaled-down neighbours keep their preview slice */
}

.track img {
  /* JS writes explicit width/height from the export's real aspect ratio
     (gallery.js fitBox); the max constraints are only a pre-JS safety net.
     object-fit: contain so a stale box (viewport changed without a resize
     event, e.g. Android Chrome's URL bar) letterboxes the photo instead of
     squeezing it: independent max-width/max-height clamps must never be
     able to distort the aspect ratio. */
  max-height: var(--img-h);
  max-width: var(--img-w);
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none; /* long-press save-image menu must not
                                  interrupt a strip drag on iOS */
  cursor: zoom-in;
}

/* ---- Focused image's title + caption: one static block, centred under the
   gallery at a FIXED vertical position (computed in JS from the maximum
   image height, not the active image, so it never moves up or down). ---- */
.now-showing {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: max-content;
  max-width: min(70ch, 86vw);
  text-align: center;
  pointer-events: none;
}
.now-showing .caption { margin-top: 2px; }

/* TEMPORARY: the photo title/caption/credit block is hidden while the
   captions are being reworked. The code and data are untouched - delete
   this one rule to show the block again. */
.now-showing { display: none; }
.now-showing .credit { color: var(--tx-2); }

/* ---- Footer: slim, quiet. Copyright left; contact + socials grouped on
   the right with a wider gap between the two groups. ---- */
.site-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: var(--bg);
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px var(--pad);
  color: var(--tx-2);
}
.foot-left { white-space: nowrap; }
.loc { margin-left: 8px; }
.loc:empty { display: none; }
.foot-right { margin-left: auto; display: flex; column-gap: 56px; row-gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.contact { display: flex; gap: 12px; flex-wrap: wrap; }
.socials { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- Zoom dialog ---- */
dialog#zoom {
  border: 0;
  background: var(--bg);
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  padding: 5vh 5vw;
  cursor: zoom-out;
  touch-action: pinch-zoom; /* allow native pinch zoom on the enlarged photo */
}
dialog#zoom:focus, dialog#zoom:focus-visible { outline: none; } /* no focus ring around the whole viewer */
dialog#zoom::backdrop { background: transparent; } /* gallery shows through while the photo animates; the dialog's own background fades (gallery.js) */
dialog#zoom picture { display: block; width: 100%; height: 100%; }
dialog#zoom img { width: 100%; height: 100%; object-fit: contain; }

/* ---- Mobile ---- */
@media (max-width: 640px) {
  :root { --img-h: 40vh; --img-w: 62vw; --gap: 40px; }

  /* Header: the site name keeps the top-left corner; the bio moves to its
     own line below it and spans the full viewport width, right aligned.
     Two line-heights down leaves a full blank line of air between the
     site name and the bio. */
  .corner-tr {
    top: 38px;
    left: 0;
    right: 0;
    max-width: none;
  }
}

/* ---- Reduced motion: plain horizontal scrolling, no easing script ---- */
/* Blur-up placeholder (see gallery.js). The preview sits inside <picture>:
   positioning/overflow on <figure> measurably delayed LCP in Lighthouse. */
.track .lqip { z-index: -1; position: absolute; inset: -12px; background-size: cover; background-position: center; filter: blur(8px); }
.track picture { position: relative; display: block; isolation: isolate; clip-path: inset(0); }
.track img.blur-pending, .track img.failed { opacity: 0; }
.track img { transition: opacity 250ms ease-out; }
@media (prefers-reduced-motion: reduce) { .track img { transition: none; } }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* ---- Pull-to-refresh on touch devices ----
   PTR fires from the rubber-band overscroll at the top of the page's scroll
   area. body { overflow: hidden } plus a page exactly viewport-height leaves
   nothing scrollable, so there is no overscroll and the gesture dies (this
   is why pull-to-refresh did nothing on iOS Safari). Give touch devices 1px
   of scrollable overflow: the fixed corners never move and the gallery can
   shift at most 1px, so the page looks identical. Desktop keeps
   overflow: hidden with zero scroll. */
@media (pointer: coarse) {
  body { overflow: visible; }
  .stage { height: calc(100vh + 1px); height: calc(100dvh + 1px); }
}

/* Visually hidden but still in the DOM for crawlers and readers (the
   EXIF span). A class, not an inline style, so the CSP needs no
   style-src exception. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- Skip link: visually hidden until keyboard focus ---- */
.skip-link {
  position: absolute;
  top: 0; left: 0;
  transform: translateY(-200%);
  z-index: 40;
  padding: 8px 12px;
  background: var(--bg);
  color: var(--tx);
  border: 1px solid var(--tx);
}
.skip-link:focus-visible { transform: none; }

/* ---- Footer tap targets: expanded CSS-pixel hit areas on the single-row
   layout; the compact two-row layout below intentionally uses less height.
   These web dimensions are not native Apple HIG compliance. ::after expands each
   link's clickable region: zero layout change - text, gaps and footer height
   are pixel-identical. Text and X are narrower than 28px, so their hit area
   extends sideways too, keeping a dead zone before neighbouring links. ---- */
.site-footer a { position: relative; }
.site-footer a::after { content: ""; position: absolute; inset: -5px 0; }
#contact a[href^="sms:"]::after { inset: -5px -2.5px; }
#socials a[href*="x.com"]::after { inset: -5px -10px; }

/* ---- Footer two-row layout ----
   Both sides break onto two lines at the same width: the single row needs
   about 681px, so below 720px the grid takes over for the left (copyright +
   location) and right (contact + socials) groups together. Rows sit 4px
   apart; the invisible hit areas are trimmed to 1.5px so they never overlap. ---- */
@media (max-width: 720px) {
  .site-footer {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 16px;
    row-gap: 4px;
    align-items: baseline;
  }
  .foot-left, .foot-right { display: contents; }
  #copyright { grid-column: 1; grid-row: 1; }
  #loc { grid-column: 1; grid-row: 2; margin-left: 0; }
  #contact { grid-column: 2; grid-row: 1; justify-self: end; }
  #socials { grid-column: 2; grid-row: 2; justify-self: end; }
  .site-footer a::after { inset: -1.5px 0; }
  #contact a[href^="sms:"]::after { inset: -1.5px -2.5px; }
  #socials a[href*="x.com"]::after { inset: -1.5px -10px; }
}

/* ---- iPhone home indicator: keep the fixed footer clear of the bottom
   safe area. No-op where env() is unsupported or there is no inset. ---- */
.site-footer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }

/* ---- Footer narrow-screen layout (360px and below) ----
   At 320px the social links no longer fit next to the copyright block at
   the standard gaps, so they wrapped onto a third line while the left
   side stayed on two. Content-sized columns with space-between, tighter
   link gaps and slightly narrower side padding keep both sides on exactly
   two matching lines. Type size, weight and the 4px row gap are
   unchanged. */
@media (max-width: 360px) {
  .site-footer {
    grid-template-columns: auto auto;
    justify-content: space-between;
    column-gap: 4px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .contact, .socials { gap: 6px; }
}

/* Preloader (preview branch): quiet Scritto word-roll before the gallery.
   Same type as everything else; background matches the page so the reveal
   is a simple 300ms ease-out fade, matching the zoom motion language. */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--tx);
  opacity: 1;
  transition: opacity 300ms ease-out;
}
#preloader.done { opacity: 0; pointer-events: none; }
#preloader scritto-text,
#preloader .pl-fallback { letter-spacing: 0.01em; }
/* ---- iPhone landscape: notch and text size ----
   Safari on iPhone inflates multi-line text blocks in landscape unless told
   not to (the bio grew past 12px and overlapped the photos). 100% keeps the
   agreed 12px / 300 everywhere; page zoom is unaffected. viewport-fit=cover
   lets the page run under the notch, so the side padding adds the left/right
   safe-area insets. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.corner {
  padding-left: max(var(--pad), env(safe-area-inset-left));
  padding-right: max(var(--pad), env(safe-area-inset-right));
}
.site-footer {
  padding-left: max(var(--pad), env(safe-area-inset-left));
  padding-right: max(var(--pad), env(safe-area-inset-right));
}
@media (max-width: 360px) {
  .site-footer {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
}

/* Landscape phones: iOS 26 can report a top inset (about 20px measured on
   the iPhone 17 family and Air). Both corners share the same top padding so
   the title and bio baselines stay aligned. No-op where there is no inset.
   Portrait is excluded: Safari's own bar already covers the top there. */
@media (orientation: landscape) and (max-height: 500px) {
  .corner { padding-top: max(var(--pad), env(safe-area-inset-top)); }
}
