/* ============================================================
   The Family Archive — visual system
   Palette: aged paper, sepia ink, faded photo-blue, warm amber
   Display: Fraunces (album-caption serif). Body: Newsreader.
   Utility/meta: IBM Plex Mono. Signature: soft film grain + a
   "taped photo corner" motif on cards.
   ============================================================ */

:root {
  --paper:      #f3ece0;   /* aged paper */
  --paper-deep: #e7ddcb;   /* deeper paper for panels */
  --ink:        #2c2620;   /* warm near-black ink */
  --ink-soft:   #6a5f50;   /* faded ink for meta */
  --amber:      #b5742a;   /* warm amber accent */
  --photo-blue: #5d7383;   /* faded photo-blue secondary */
  --line:       #d4c8b2;   /* hairline on paper */
  --good:       #4d7a4e;
  --bad:        #a8442e;
  --radius:     3px;
  --maxw:       1040px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  /* Film-grain signature: subtle layered noise + vignette warmth */
  background-image:
    radial-gradient(120% 90% at 50% -10%, rgba(181,116,42,0.10), transparent 60%),
    radial-gradient(140% 120% at 50% 120%, rgba(93,115,131,0.10), transparent 55%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* grain overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.45;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

a { color: var(--amber); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }

/* ---------- layout ---------- */
.wrap {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.4rem 1.4rem 3rem;
  flex: 1 0 auto;
}
.wrap.narrow { max-width: 560px; }

/* ---------- top bar ---------- */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.4rem;
  max-width: var(--maxw);
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 0.5rem; text-decoration: none; }
.brand-mark { color: var(--amber); font-size: 1.1rem; transform: translateY(1px); }
.brand-name {
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.nav { display: flex; align-items: center; gap: 1.25rem; }
.nav a {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-decoration: none;
}
.nav a:hover { color: var(--amber); }
.nav-quiet { opacity: 0.7; }

/* ---------- headings ---------- */
h1, h2, h3 { font-family: "Fraunces", serif; font-weight: 600; line-height: 1.15; color: var(--ink); }
h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0 0 0.4rem; }
h2 { font-size: 1.5rem; margin: 0 0 0.6rem; }
.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--amber);
  margin: 0 0 0.5rem;
}

/* ---------- flashes ---------- */
.flashes { margin-bottom: 1.4rem; display: grid; gap: 0.5rem; }
.flash {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  border-left: 3px solid var(--ink-soft);
  background: var(--paper-deep);
  font-size: 0.95rem;
}
.flash-error { border-left-color: var(--bad); }
.flash-success { border-left-color: var(--good); }

/* ---------- home intro / request block ---------- */
.intro { margin-bottom: 2.2rem; }
.intro p.lede { font-size: 1.18rem; color: var(--ink-soft); margin: 0.2rem 0 0; max-width: 60ch; }

.request-card {
  margin: 2rem 0 2.6rem;
  padding: 1.5rem 1.6rem;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
}
.request-card::before {
  /* taped-corner motif */
  content: "";
  position: absolute;
  top: -10px; left: 24px;
  width: 64px; height: 22px;
  background: rgba(181,116,42,0.18);
  border: 1px solid rgba(181,116,42,0.3);
  transform: rotate(-3deg);
}
.request-card h2 { margin-top: 0.3rem; }
.request-card p { margin: 0; max-width: 62ch; }
.request-card .cta { margin-top: 1rem; }

/* ---------- search & tag filter ---------- */
.toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.6rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
}
.search { flex: 1 1 260px; }
.search input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font-family: "Newsreader", serif;
  font-size: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
}
.search input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }

.tagchips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  text-decoration: none;
  cursor: pointer;
}
.chip:hover { border-color: var(--amber); color: var(--amber); }
.chip.active { background: var(--amber); border-color: var(--amber); color: var(--paper); }

/* ---------- video grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.6rem;
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(44,38,32,0.14); }
.thumb {
  aspect-ratio: 16 / 9;
  background: var(--photo-blue);
  background-size: cover;
  background-position: center;
  position: relative;
  filter: saturate(0.9) contrast(0.96);
}
.thumb::after {
  content: "▶";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: rgba(243,236,224,0.92);
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.card-body { padding: 0.9rem 1rem 1.1rem; }
.card-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.12rem; margin: 0 0 0.3rem; }
.card-meta { font-family: "IBM Plex Mono", monospace; font-size: 0.72rem; color: var(--ink-soft); letter-spacing: 0.04em; }
.card-tags { margin-top: 0.55rem; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.card-tags span {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--photo-blue);
}
.card-tags span::before { content: "#"; opacity: 0.6; }

/* ---------- empty state ---------- */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- video detail ---------- */
.player {
  aspect-ratio: 16 / 9;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  margin-bottom: 1.2rem;
}
.player iframe { width: 100%; height: 100%; border: 0; border-radius: var(--radius); }
.detail-meta { font-family: "IBM Plex Mono", monospace; font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 0.6rem; }
.detail-desc { max-width: 70ch; }
.backlink { font-family: "IBM Plex Mono", monospace; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- forms ---------- */
.form { max-width: 620px; }
.field { margin-bottom: 1.2rem; }
.field label {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
}
.field .optional { opacity: 0.6; text-transform: none; letter-spacing: 0; }
.field input, .field textarea, .field input[type="file"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font-family: "Newsreader", serif;
  font-size: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.hint-text { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.3rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.65rem 1.2rem;
  background: var(--amber);
  color: var(--paper);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); background: transparent; color: var(--ink); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: var(--paper); border-color: var(--bad); }
.btn-row { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; }

/* ---------- login ---------- */
.login-card {
  max-width: 420px;
  margin: 6vh auto 0;
  text-align: center;
}
.login-card .brand-name { font-size: 2.2rem; display: block; margin-bottom: 0.2rem; }
.login-sub { color: var(--ink-soft); margin: 0 0 2rem; }
.hint-box {
  margin-top: 1.4rem;
  padding: 0.9rem 1rem;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.hint-box strong { color: var(--ink); font-weight: 600; }

/* ---------- manage table ---------- */
.mtable { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.95rem; }
.mtable th, .mtable td { text-align: left; padding: 0.7rem 0.6rem; border-bottom: 1px solid var(--line); }
.mtable th { font-family: "IBM Plex Mono", monospace; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.mtable .row-actions { display: flex; gap: 0.5rem; }
.mtable .row-actions form { display: inline; }

/* ---------- footer ---------- */
.footer {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  text-align: center;
  padding: 1.6rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}

/* ---------- page header row ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .nav { gap: 0.9rem; }
  .grid { grid-template-columns: 1fr; }
  .topbar { padding: 0.8rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .card:hover { transform: none; }
}

/* ---------- upload progress ---------- */
.mono { font-family: "IBM Plex Mono", monospace; }
.upload-progress {
  margin: 0.4rem 0 1.4rem;
  padding: 1.1rem 1.2rem;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.upload-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}
.upload-progress-head span:first-child {
  font-family: "Fraunces", serif;
  font-size: 1.05rem;
  color: var(--ink);
}
#progress-pct { font-size: 0.9rem; color: var(--amber); }
.progress-track {
  width: 100%;
  height: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--amber), #c98a45);
  border-radius: 999px;
  transition: width 0.18s ease;
}
#progress-detail { margin: 0.55rem 0 0; }
.upload-warning { color: var(--photo-blue); margin-top: 0.2rem; }

@media (prefers-reduced-motion: reduce) {
  .progress-fill { transition: none; }
}

/* ---------- privacy note ---------- */
.privacy-note {
  margin: 0 0 2.2rem;
  padding: 0.85rem 1.1rem;
  max-width: 70ch;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-soft);
  background: rgba(93,115,131,0.07);
  border-left: 3px solid var(--photo-blue);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.privacy-note-label {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--photo-blue);
  margin-bottom: 0.3rem;
}
.privacy-note strong { color: var(--ink); font-weight: 600; }
