/* ======================================================================
   PORTFOLIO — design tokens
   A photography case-study viewer: the image always fills the frame,
   text floats above it as a single Material "surface" rather than
   competing page chrome. Motion is Material-style (elevation + a single
   crossfade on slide change) but the palette and type are editorial:
   warm near-black, brass accent, a serif display paired with a plain
   sans for UI and body copy.
   ====================================================================== */

:root{
  /* color */
  --ink:        #15110d;   /* base background, warm near-black */
  --ink-soft:   #221c17;   /* elevated dark surface (the story card) */
  --ink-line:   rgba(247,243,236,0.14);
  --paper:      #f7f3ec;   /* text on dark, chrome on light */
  --paper-dim:  #cfc7b8;   /* secondary text on dark */
  --brass:      #b68d4c;   /* accent — used sparingly: stats, active state */
  --brass-hi:   #d9b47c;
  --smoke:      #9a9285;

  /* elevation — Material's two-shadow (key + ambient) system */
  --e1: 0 1px 2px rgba(0,0,0,.30), 0 1px 3px 1px rgba(0,0,0,.20);
  --e3: 0 1px 3px rgba(0,0,0,.35), 0 4px 12px 2px rgba(0,0,0,.30);
  --e6: 0 2px 6px rgba(0,0,0,.40), 0 8px 24px 4px rgba(0,0,0,.35);

  /* type */
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* motion */
  --ease: cubic-bezier(.2,.0,.2,1);
  --dur-s: 180ms;
  --dur-m: 420ms;

  color-scheme: dark;
}

*, *::before, *::after{ box-sizing: border-box; }

html, body{
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body{ overflow: hidden; }

a{ color: inherit; }

button{
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

::selection{ background: var(--brass); color: var(--ink); }

/* The `hidden` attribute must always win over any `display` a class sets
   (modal, modal-actions, queue-strip, etc. all set display:flex/block).
   Without this, an author rule with equal specificity can silently
   override [hidden] and the element renders even while "hidden". */
[hidden]{ display: none !important; }

/* focus ring — always visible, never suppressed */
:focus-visible{
  outline: 2px solid var(--brass-hi);
  outline-offset: 3px;
}

/* ======================================================================
   Shell
   ====================================================================== */

.viewer{
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* ---- Top bar: brand + story tabs ---------------------------------- */

.topbar{
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1.4rem clamp(1.25rem, 4vw, 3rem);
  background: linear-gradient(to bottom, rgba(10,8,6,.75) 0%, rgba(10,8,6,0) 100%);
  pointer-events: none;
}

.topbar > *{ pointer-events: auto; }

.brand{
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}

.brand small{
  display: block;
  font-family: var(--sans);
  font-size: .6875rem;
  font-weight: 500;
  color: var(--paper-dim);
  letter-spacing: .03em;
  margin-top: .1rem;
}

.story-tabs{
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.story-tabs::-webkit-scrollbar{ display: none; }

.story-tab{
  flex: none;
  padding: .5rem .9rem;
  border-radius: 100px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--paper-dim);
  border: 1px solid transparent;
  transition: background var(--dur-s) var(--ease), color var(--dur-s) var(--ease), border-color var(--dur-s) var(--ease);
  white-space: nowrap;
}

.story-tab:hover{ color: var(--paper); }

.story-tab[aria-selected="true"]{
  color: var(--ink);
  background: var(--paper);
}

/* ======================================================================
   Stage — the full-bleed photograph
   ====================================================================== */

.stage{
  position: absolute;
  inset: 0;
}

.frame{
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity var(--dur-m) var(--ease), transform 900ms var(--ease);
  will-change: opacity, transform;
}

.frame.is-active{
  opacity: 1;
  transform: scale(1);
  z-index: 1;
}

.frame img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.frame::after{
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(8,6,4,.82) 0%, rgba(8,6,4,.15) 42%, rgba(8,6,4,0) 60%);
}

@media (min-width: 900px){
  .frame::after{
    background: linear-gradient(100deg, rgba(8,6,4,.86) 0%, rgba(8,6,4,.55) 30%, rgba(8,6,4,0) 58%),
                linear-gradient(to top, rgba(8,6,4,.55) 0%, rgba(8,6,4,0) 30%);
  }
}

/* ======================================================================
   Story card — the Material surface holding the writeup
   ====================================================================== */

.storycard{
  position: absolute;
  z-index: 20;
  left: clamp(1.25rem, 4vw, 3rem);
  right: clamp(1.25rem, 4vw, 3rem);
  bottom: 6.5rem;
  max-width: 30rem;
  background: rgba(21, 17, 13, .58);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--ink-line);
  border-radius: 18px;
  box-shadow: var(--e3);
  padding: 1.6rem 1.7rem 1.5rem;
  transition: box-shadow var(--dur-s) var(--ease), background var(--dur-s) var(--ease), padding var(--dur-s) var(--ease);
}

.storycard:hover, .storycard:focus-within{
  box-shadow: var(--e6);
}

/* the text scrolls in its own box so the toggle button (below) never
   gets carried out of view while reading a long story. Scrollbar is
   themed thin/translucent instead of the browser's default bar so it
   doesn't visually compete with the collapse button above it. */
.storycard-content{
  max-height: 58vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: .6rem;
  margin-right: -.6rem;
   top: .65rem;
  scrollbar-width: thin;                          /* Firefox */
  scrollbar-color: rgba(217,180,124,.5) transparent; /* Firefox */
}
.storycard-content::-webkit-scrollbar{             /* Chrome / Safari / Edge */
  width: 5px;
}
.storycard-content::-webkit-scrollbar-track{
  background: transparent;
}
.storycard-content::-webkit-scrollbar-thumb{
  background: rgba(217,180,124,.5);
  border-radius: 999px;
}
.storycard-content::-webkit-scrollbar-thumb:hover{
  background: rgba(217,180,124,.85);
}

.storycard .eyebrow{
  font-size: .75rem;
  font-weight: 500;
  color: var(--brass-hi);
  margin: 0 0 .5rem;
  padding-right: 2.4rem; /* keep clear of the collapse button */
}

.storycard h1{
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 3.4vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -.01em;
  margin: 0 0 .55rem;
  padding-right: 2rem; /* keep clear of the collapse button */
}

/* ---- collapse / reveal toggle -------------------------------------- */

.card-toggle{
  position: absolute;
 top: 1.55rem;
  left: 25rem;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--ink-line);
  transition: background var(--dur-s) var(--ease), box-shadow var(--dur-s) var(--ease);
}
.card-toggle:hover{ background: rgba(182,141,76,.28); }
.card-toggle svg{
  width: 16px;
  height: 16px;
  fill: var(--paper);
  transition: transform var(--dur-s) var(--ease);
}

/* collapsed: the card shrinks down to just the reveal button so the
   photo underneath is fully visible, same as before a story is opened */
/* collapsed: the card's own footprint never moves — only its backdrop,
   border, and text fade away, leaving the toggle button exactly where
   it already was (top-right) so it never jumps position. The rest of
   the (now invisible) card box lets clicks pass through to the photo. */
.storycard.is-collapsed{
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
  top:10%;
}
.storycard.is-collapsed .storycard-content{ display: none; }
.storycard.is-collapsed .card-toggle{
  pointer-events: auto;
  background: rgba(21,17,13,.55);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--e3);
   top: 0;
   left: 0;
}
.storycard.is-collapsed .card-toggle svg{ transform: rotate(180deg); }

.storycard .stat{
  display: inline-flex;
  align-items: baseline;
  gap: .4rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--brass-hi);
  margin: 0 0 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--ink-line);
  width: 100%;
}

.storycard .location{
  font-size: .8rem;
  color: var(--smoke);
  font-weight: 500;
}

.storycard p{
  font-size: .95rem;
  line-height: 1.62;
  color: var(--paper-dim);
  margin: 0 0 .95rem;
  max-width: 62ch;
}

.storycard p:last-child{ margin-bottom: 0; }

.storycard .toggle-full{
  font-size: .8125rem;
  font-weight: 600;
  color: var(--brass-hi);
  padding: 0;
  margin-top: .25rem;
  border-bottom: 1px solid transparent;
}
.storycard .toggle-full:hover{ border-color: var(--brass-hi); }

.storycard p.is-clamped{
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ======================================================================
   Controls: prev/next FABs, image dots, filmstrip
   ====================================================================== */

.nav-fab{
  position: absolute;
  z-index: 25;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(21,17,13,.55);
  border: 1px solid var(--ink-line);
  backdrop-filter: blur(10px);
  box-shadow: var(--e1);
  transition: box-shadow var(--dur-s) var(--ease), background var(--dur-s) var(--ease), transform var(--dur-s) var(--ease);
  overflow: hidden;
}
.nav-fab:hover{ background: rgba(182,141,76,.28); box-shadow: var(--e3); }
.nav-fab:active{ transform: translateY(-50%) scale(.94); }
.nav-fab.prev{ left: clamp(.75rem, 2.5vw, 2rem); }
.nav-fab.next{ right: clamp(.75rem, 2.5vw, 2rem); }
.nav-fab svg{ width: 20px; height: 20px; fill: var(--paper); }

.dots{
  position: absolute;
  z-index: 25;
  right: clamp(1.25rem, 4vw, 3rem);
  bottom: 2.5rem;
  display: flex;
  gap: .4rem;
}
.dot{
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(247,243,236,.35);
  transition: background var(--dur-s) var(--ease), transform var(--dur-s) var(--ease), width var(--dur-s) var(--ease);
}
.dot[aria-current="true"]{
  background: var(--brass-hi);
  width: 20px;
  border-radius: 4px;
}

.filmstrip{
  position: absolute;
  z-index: 25;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: .5rem;
  padding: 0 clamp(1.25rem, 4vw, 3rem) 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.filmstrip::-webkit-scrollbar{ display: none; }

.filmstrip button{
  flex: none;
  width: 64px;
  height: 42px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  opacity: .55;
  box-shadow: var(--e1);
  transition: opacity var(--dur-s) var(--ease), border-color var(--dur-s) var(--ease);
}
.filmstrip button.is-active{
  opacity: 1;
  border-color: var(--brass-hi);
}
.filmstrip img{
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* progress caption, top-right */
.meta{
  position: absolute;
  z-index: 25;
  right: clamp(1.25rem, 4vw, 3rem);
  top: 1.5rem;
  font-size: .75rem;
  color: var(--paper-dim);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* ripple */
.ripple{
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.45);
  transform: scale(0);
  animation: ripple 550ms var(--ease);
  pointer-events: none;
}
@keyframes ripple{ to{ transform: scale(2.6); opacity: 0; } }

/* ======================================================================
   Empty state (no stories in photos.json yet)
   ====================================================================== */

.empty{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  text-align: center;
  padding: 2rem;
}
.empty h1{ font-family: var(--serif); font-size: 1.8rem; margin: 0; }
.empty p{ color: var(--paper-dim); max-width: 32rem; margin: 0; }
.empty a{ color: var(--brass-hi); font-weight: 600; }

/* ======================================================================
   Responsive
   ====================================================================== */

@media (max-width: 720px){
  body{ overflow-y: auto; }
  .topbar{ padding: 1rem 1rem; gap: 1rem; }
  .brand small{ display: none; }

  .storycard{
    left: .75rem; right: .75rem;
    bottom: 4.75rem;
    padding: 1.15rem 1.15rem 1.1rem;
    border-radius: 16px;
  }
  .storycard-content{ max-height: 40vh; }
  .storycard h1{ font-size: 1.5rem; }
  .storycard p{ font-size: .9rem; }

  .nav-fab{ width: 40px; height: 40px; }
  .nav-fab.prev{ left: .5rem; }
  .nav-fab.next{ right: .5rem; }

  .dots{ display: none; }
  .filmstrip button{ width: 52px; height: 36px; }
  .meta{ top: 1rem; }
}

@media (prefers-reduced-motion: reduce){
  .frame, .dot, .story-tab, .nav-fab, .storycard{ transition: none !important; animation: none !important; }
  .frame{ transform: none !important; }
}

/* ======================================================================
   Admin (admin.php) — light Material form surface, separate from viewer
   ====================================================================== */

.admin-body{
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
}
.admin-wrap{
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem) 1.25rem 4rem;
}
.admin-wrap h1{
  font-family: var(--serif);
  font-size: 2rem;
  margin: 0 0 .25rem;
}
.admin-wrap > p.lede{
  color: #6b6357;
  margin: 0 0 2rem;
}
.card{
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(20,15,8,.06), 0 6px 20px rgba(20,15,8,.08);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.field{ margin-bottom: 1.25rem; }
.field label{
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: #48413a;
}
.field .hint{
  display: block;
  font-size: .75rem;
  color: #8c8474;
  margin-top: .35rem;
}
.field input[type=text],
.field textarea{
  width: 100%;
  border: 1px solid #ddd4c2;
  border-radius: 8px;
  padding: .65rem .75rem;
  font-family: var(--sans);
  font-size: .9rem;
  background: #fdfcf9;
  color: var(--ink);
  resize: vertical;
}
.field input:focus, .field textarea:focus{
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(182,141,76,.18);
}
.btn{
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--ink);
  color: var(--paper);
  padding: .75rem 1.4rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: .875rem;
  box-shadow: var(--e1);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--dur-s) var(--ease), transform var(--dur-s) var(--ease);
}
.btn:hover{ box-shadow: var(--e3); }
.btn:active{ transform: scale(.98); }
.btn.danger{ background: #8a3324; }
.btn.ghost{
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  border: 1px solid #ddd4c2;
}

.notice{
  border-radius: 10px;
  padding: .85rem 1rem;
  font-size: .875rem;
  margin-bottom: 1.5rem;
}
.notice.success{ background: #eaf3ea; color: #285c2b; }
.notice.error{ background: #f6e6e2; color: #8a3324; }

.story-row{
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 0;
  border-top: 1px solid #eee6d8;
}
.story-row:first-child{ border-top: none; }
.story-row img{
  width: 76px; height: 52px; object-fit: cover; border-radius: 6px; flex: none;
  background: #eee6d8;
}
.story-row .info{ flex: 1; min-width: 0; }
.story-row .info strong{ display: block; font-size: .95rem; }
.story-row .info span{ font-size: .8rem; color: #8c8474; }

/* ======================================================================
   Staging banner (staging-index.php)
   ====================================================================== */

.staging-banner{
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: var(--brass);
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 600;
}
.staging-banner a{
  text-decoration: underline;
  font-weight: 600;
}

.viewer.staging{
  top: 2.5rem;
  height: calc(100% - 2.5rem);
}

/* ======================================================================
   Admin — publish bar
   ====================================================================== */

.publish-bar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: #efe9db;
  border: 1px solid #ddd4c2;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.publish-bar.has-changes{
  background: #fbf1de;
  border-color: var(--brass);
}
.publish-bar-text strong{ display: block; font-size: .9rem; }
.publish-bar-text span{ font-size: .8rem; color: #8c8474; }
.publish-bar-actions{ display: flex; gap: .5rem; flex-wrap: wrap; }
.publish-bar-actions .btn[disabled]{
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

/* ======================================================================
   Admin — upload row + queued photo chips
   ====================================================================== */

.upload-row{
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .65rem;
}
.upload-row .hint{ margin: 0; }

.queue-strip{
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: .85rem;
}
.queue-chip{
  display: flex;
  align-items: center;
  gap: .5rem;
  background: #fdfcf9;
  border: 1px solid #ddd4c2;
  border-radius: 10px;
  padding: .35rem .5rem .35rem .35rem;
  max-width: 220px;
}
.queue-chip img{
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: 6px;
  flex: none;
}
.queue-chip-caption{
  font-size: .75rem;
  color: #6b6357;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-chip button{
  flex: none;
  font-size: 1.1rem;
  line-height: 1;
  color: #8c8474;
  padding: 0 .1rem;
}
.queue-chip button:hover{ color: #8a3324; }

/* ======================================================================
   Admin — upload confirmation modal
   ====================================================================== */

.modal-overlay{
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(21,17,13,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.modal{
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--e6);
  width: 100%;
  max-width: 26rem;
  overflow: hidden;
}
.modal-preview{
  width: 100%;
  height: 220px;
  background: #efe9db;
}
.modal-preview img{
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.modal-body{ padding: 1.5rem; }
.modal-body h2{
  font-family: var(--serif);
  font-size: 1.3rem;
  margin: 0 0 .3rem;
}
.modal-status{
  font-size: .85rem;
  color: #8c8474;
  margin: 0 0 1rem;
  word-break: break-word;
}
.modal-actions{
  display: flex;
  gap: .6rem;
  margin-top: .5rem;
}
