/* =========================================================================
   Aislerman's Apps — Family Library
   A small, hand-bound book of programs we made for our children.
   --------------------------------------------------------------------------
   Aesthetic: warm cream paper, oxblood ink, faded ochre ornament.
   Typography: DM Serif Display (titles), Newsreader (body), Caveat (hand).
   ========================================================================= */

/* --- Color, Type, and Scale --------------------------------------------- */
:root {
  /* Paper & ink */
  --paper:        #f4ecd8;
  --paper-deep:   #ead9b8;
  --paper-edge:   #d8c4a0;
  --paper-shadow: rgba(74, 53, 40, 0.10);

  --ink:          #2a1810;
  --ink-soft:     #4a3528;
  --ink-fade:     #8a6f5c;
  --ink-whisper:  #b39a82;

  /* Colors of ribbon, gilt edge, and seal-wax */
  --accent:       #8b2f2f;   /* oxblood */
  --accent-deep:  #5a1b1d;
  --gold:         #b8893d;   /* faded ochre */
  --gold-deep:    #8a6529;
  --sage:         #6b7d5a;
  --plum:         #6b4566;

  --rule:         #c4ad88;
  --rule-soft:    #d9c6a0;

  /* Type */
  --font-display: "DM Serif Display", "Cormorant Garamond", Georgia, serif;
  --font-body:    "Newsreader", "Source Serif Pro", Georgia, serif;
  --font-hand:    "Caveat", "Dancing Script", cursive;

  /* Geometry */
  --measure: 60ch;
  --max:    980px;
  --radius: 6px;       /* keep things flat-ish, like printed paper */
  --rule-w: 1px;

  /* Motion */
  --ease-paper: cubic-bezier(.22, .61, .36, 1);
}

/* --- Reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }

/* --- Page ---------------------------------------------------------------- */
html {
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "onum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  position: relative;
  background:
    radial-gradient(ellipse at top, rgba(255, 245, 220, 0.6), transparent 70%),
    radial-gradient(ellipse at bottom right, rgba(184, 137, 61, 0.08), transparent 55%),
    var(--paper);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Paper grain — a very subtle fractal noise layered over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.16  0 0 0 0 0.10  0 0 0 0 0.06  0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.35;
  mix-blend-mode: multiply;
}

/* A faint vignette at the page edges, like an old book scan */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse at center, transparent 60%, rgba(74, 53, 40, 0.15) 100%);
}

/* Keep real content above the texture layers */
.site-header, main, footer { position: relative; z-index: 2; }


/* --- Site header (the imprint plate) ------------------------------------- */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding: 1.4rem clamp(1.25rem, 4vw, 3rem);
  border-bottom: var(--rule-w) solid var(--rule-soft);
  border-bottom-style: double;
  border-bottom-width: 3px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: 0;
  line-height: 1;
}
.brand-mark {
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 2.8vw, 1.85rem);
  font-style: italic;
  color: var(--accent-deep);
  letter-spacing: -0.01em;
}
.brand-orn {
  color: var(--gold);
  font-size: 0.9em;
  position: relative;
  top: -0.05em;
}
.brand-tag {
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-fade);
  font-weight: 500;
}

.site-nav {
  display: flex;
  align-items: baseline;
  gap: clamp(0.75rem, 2.5vw, 1.5rem);
  font-size: 0.95rem;
}
.site-nav .who {
  font-family: var(--font-hand);
  font-size: 1.25rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}
.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .2s var(--ease-paper), color .2s var(--ease-paper);
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
}
.site-nav a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Main container ------------------------------------------------------ */
.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4.5rem) clamp(1.25rem, 4vw, 3rem) 6rem;
}

/* --- Typography ---------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 0.6em;
}

h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  letter-spacing: -0.02em;
}
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.35rem); }

p { margin: 0 0 1.1em; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color .15s var(--ease-paper), border-color .15s var(--ease-paper);
}
a:hover { color: var(--accent-deep); border-bottom-color: var(--accent); }

em, i { font-style: italic; }
strong, b { font-weight: 600; color: var(--ink); }

.muted { color: var(--ink-fade); }
.hand  { font-family: var(--font-hand); font-size: 1.25em; color: var(--ink-soft); }
.smallcaps {
  font-variant: small-caps;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--ink-fade);
  font-size: 0.95em;
}

/* Ornaments — used decoratively, never decoratively-required */
.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  color: var(--gold);
  font-size: 1.1rem;
  letter-spacing: 0.4em;
  margin: 1.75rem 0;
}
.ornament::before, .ornament::after {
  content: "";
  flex: 1;
  height: 1px;
  background:
    linear-gradient(to right, transparent, var(--rule) 20%, var(--rule) 80%, transparent);
}
.ornament-glyph {
  color: var(--gold-deep);
  font-style: normal;
  user-select: none;
}

/* --- Frontispiece / hero (used on dashboard top) ------------------------- */
.frontispiece {
  text-align: center;
  margin-bottom: 2.5rem;
}
.frontispiece .eyebrow {
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 0.4rem;
}
.frontispiece h1 {
  font-style: italic;
  margin-bottom: 0.2rem;
  color: var(--accent-deep);
}
.frontispiece .by-hand {
  font-family: var(--font-hand);
  font-size: 1.7rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

/* --- Card (auth forms, single-purpose pages) ----------------------------- */
.card {
  background: linear-gradient(180deg, #fbf5e2, var(--paper) 80%);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  padding: clamp(1.75rem, 5vw, 2.75rem) clamp(1.5rem, 5vw, 2.5rem);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  box-shadow:
    0 1px 0 #fff inset,
    0 1px 2px var(--paper-shadow),
    0 12px 32px -16px rgba(90, 27, 29, 0.18);
}

/* Decorative double-rule frame inside the card */
.card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid var(--rule-soft);
  border-radius: calc(var(--radius) - 2px);
  pointer-events: none;
  opacity: 0.55;
}

.card h1 {
  font-size: clamp(1.8rem, 4vw, 2.3rem);
  text-align: center;
  margin: 0;
  font-style: italic;
  color: var(--accent-deep);
}
.card .lede {
  text-align: center;
  color: var(--ink-fade);
  font-style: italic;
  margin: 0.4rem 0 1.4rem;
}

/* --- Forms (writing on a ruled page) ------------------------------------- */
form label {
  display: block;
  margin: 1.25rem 0 0;
  font-variant: small-caps;
  letter-spacing: 0.14em;
  font-size: 0.85rem;
  color: var(--ink-fade);
}

form input[type="email"],
form input[type="text"],
form input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.7rem 0.25rem 0.6rem;
  font: 400 1.05rem/1.4 var(--font-body);
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--rule);
  border-radius: 0;
  transition: border-color .15s var(--ease-paper);
  font-variant-numeric: oldstyle-nums;
}
form input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}
form input::placeholder { color: var(--ink-whisper); font-style: italic; }

/* "Stay signed in" — inline checkbox with handwritten flavor */
form label.remember {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 1.4rem 0 0.4rem;
  font-variant: normal;
  letter-spacing: 0;
  text-transform: none;
  font-size: 1.05rem;
  font-family: var(--font-hand);
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
form label.remember input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  border: 1.5px solid var(--rule);
  background: #fdfaf0;
  border-radius: 3px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  transition: border-color .15s var(--ease-paper), background-color .15s;
}
form label.remember input[type="checkbox"]:hover { border-color: var(--gold); }
form label.remember input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent);
}
form label.remember input[type="checkbox"]:checked::before {
  content: "✓";
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 0.85rem;
  line-height: 1;
  font-weight: 700;
}
form label.remember input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* The big oxblood "stamp" button */
button, .button {
  display: inline-block;
  margin-top: 1.6rem;
  padding: 0.7rem 1.6rem;
  font: 500 0.95rem/1 var(--font-body);
  font-variant: small-caps;
  letter-spacing: 0.22em;
  color: var(--paper);
  background: var(--accent);
  border: 1px solid var(--accent-deep);
  border-radius: 3px;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 230, 200, 0.25) inset,
    0 2px 0 var(--accent-deep),
    0 6px 18px -6px rgba(90, 27, 29, 0.45);
  transition: transform .12s var(--ease-paper), box-shadow .12s var(--ease-paper);
}
button:hover {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 rgba(255, 230, 200, 0.2) inset,
    0 1px 0 var(--accent-deep),
    0 4px 12px -4px rgba(90, 27, 29, 0.45);
}
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-deep); }
button.danger { background: var(--plum); border-color: #4a304b; box-shadow: 0 2px 0 #4a304b, 0 6px 18px -6px rgba(75,40,75,.4); }
button.danger:hover { box-shadow: 0 1px 0 #4a304b, 0 4px 12px -4px rgba(75,40,75,.4); }
button.ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  box-shadow: none;
}
button.ghost:hover { color: var(--accent); border-color: var(--accent); }

/* --- Flash / alerts (the bookseller's reading slip) ---------------------- */
.error, .success {
  margin: 0 0 1rem;
  padding: 0.7rem 1rem;
  border-left: 3px solid;
  font-style: italic;
  background: rgba(255, 250, 235, 0.65);
}
.error    { border-color: var(--accent); color: var(--accent-deep); }
.success  { border-color: var(--sage);   color: #3f5235; }


/* =========================================================================
   Dashboard — A Table of Contents
   ========================================================================= */

.welcome {
  margin-bottom: 2.5rem;
  text-align: center;
}
.welcome .salutation {
  font-family: var(--font-hand);
  font-size: 2.2rem;
  color: var(--ink-soft);
  line-height: 1;
  margin: 0 0 0.4rem;
}
.welcome .salutation em {
  font-style: normal;
  color: var(--accent-deep);
}
.welcome .lede {
  color: var(--ink-fade);
  font-style: italic;
  max-width: 32rem;
  margin: 0 auto;
}

.toc-label {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin: 2.5rem 0 1.5rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-fade);
}
.toc-label::after {
  content: "";
  flex: 1;
  height: 0;
  border-bottom: 1px solid var(--rule);
  position: relative;
  top: -0.25em;
}

/* The list of "chapters" — one per app */
.toc {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}

.toc-entry {
  display: grid;
  grid-template-columns: 3.5rem 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "num   title  emoji"
    "num   desc   emoji";
  align-items: baseline;
  gap: 0.2rem 1.25rem;
  padding: 1.4rem 0.5rem 1.4rem;
  border-bottom: 1px dotted var(--rule);
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: background-color .25s var(--ease-paper), padding .25s var(--ease-paper);
}
.toc-entry:first-child { border-top: 1px dotted var(--rule); }
.toc-entry:hover {
  background: linear-gradient(90deg, rgba(184, 137, 61, 0.05), transparent 60%);
  padding-left: 1.25rem;
}
.toc-entry:hover .toc-title { color: var(--accent-deep); }
.toc-entry:hover .toc-emoji { transform: rotate(-4deg) scale(1.06); }

.toc-num {
  grid-area: num;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--gold);
  font-style: italic;
  text-align: right;
  font-variant-numeric: oldstyle-nums;
  letter-spacing: 0.04em;
  line-height: 1;
  align-self: center;
}

.toc-title {
  grid-area: title;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 3.4vw, 1.85rem);
  color: var(--ink);
  line-height: 1.1;
  margin: 0;
  font-weight: 400;
  transition: color .2s var(--ease-paper);
}
.toc-tag {
  display: inline-block;
  margin-left: 0.6rem;
  font-family: var(--font-body);
  font-variant: small-caps;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--gold-deep);
  vertical-align: 0.25em;
}

.toc-desc {
  grid-area: desc;
  font-style: italic;
  color: var(--ink-fade);
  margin: 0.1rem 0 0;
  font-size: 0.98rem;
  line-height: 1.5;
}

.toc-emoji {
  grid-area: emoji;
  font-size: clamp(2.5rem, 6vw, 3.2rem);
  line-height: 1;
  align-self: center;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.6))
          drop-shadow(0 2px 5px rgba(74, 53, 40, 0.15));
  transition: transform .35s var(--ease-paper);
  user-select: none;
}

/* Colophon at the foot of the dashboard */
.colophon {
  margin-top: 4rem;
  text-align: center;
  color: var(--ink-fade);
  font-style: italic;
  font-size: 0.95rem;
}
.colophon .glyph { color: var(--gold); margin: 0 0.45em; }


/* =========================================================================
   Admin — The Guest Register
   ========================================================================= */

.register-block { margin-bottom: 2.5rem; }
.register-block h2 {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  font-style: italic;
  font-weight: 400;
  margin: 0 0 1.1rem;
}
.register-block h2 .count {
  font-family: var(--font-body);
  font-style: normal;
  font-variant: small-caps;
  letter-spacing: 0.16em;
  font-size: 0.8rem;
  color: var(--ink-fade);
  padding: 0.1rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(255, 250, 235, 0.55);
}

table.users {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.97rem;
  background: rgba(255, 250, 235, 0.45);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
table.users thead th {
  text-align: left;
  padding: 0.7rem 0.9rem;
  font-variant: small-caps;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--ink-fade);
  font-weight: 500;
  border-bottom: 1px solid var(--rule);
  background: rgba(216, 196, 160, 0.18);
}
table.users tbody td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px dotted var(--rule-soft);
  vertical-align: middle;
}
table.users tbody tr:last-child td { border-bottom: 0; }
table.users tbody tr:hover { background: rgba(184, 137, 61, 0.06); }

table.users td form { display: inline; margin: 0; }
table.users td button {
  margin: 0 0.2rem 0 0;
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  box-shadow: 0 1px 0 var(--accent-deep);
}
table.users td button.danger { box-shadow: 0 1px 0 #4a304b; }

.badge {
  display: inline-block;
  font-family: var(--font-body);
  font-variant: small-caps;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--paper);
  background: var(--gold-deep);
  padding: 0.05rem 0.55rem;
  border-radius: 2px;
  margin-left: 0.5em;
  vertical-align: 0.1em;
}

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-fade);
  font-style: italic;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  background: rgba(255, 250, 235, 0.45);
}


/* =========================================================================
   Page-load motion — staggered, gentle (one-time, on first paint)
   ========================================================================= */
@keyframes leaf-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.frontispiece, .welcome, .card, .toc-label, .ornament {
  animation: leaf-in .55s var(--ease-paper) both;
}
.toc-entry { animation: leaf-in .5s var(--ease-paper) both; }
.toc-entry:nth-child(1) { animation-delay: .05s; }
.toc-entry:nth-child(2) { animation-delay: .12s; }
.toc-entry:nth-child(3) { animation-delay: .19s; }
.toc-entry:nth-child(4) { animation-delay: .26s; }
.toc-entry:nth-child(5) { animation-delay: .33s; }
.colophon { animation: leaf-in .55s .55s var(--ease-paper) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1.1rem 1.25rem;
  }
  .site-nav { width: 100%; justify-content: space-between; }
  .container { padding-top: 1.75rem; }

  .toc-entry {
    grid-template-columns: 2.4rem 1fr;
    grid-template-areas:
      "num   emoji"
      "num   title"
      "num   desc";
    gap: 0.25rem 0.9rem;
    padding: 1.1rem 0.25rem;
  }
  .toc-emoji {
    font-size: 2.4rem;
    align-self: start;
    justify-self: start;
  }
  .toc-num { font-size: 1.2rem; align-self: start; padding-top: 0.4rem; }
  .toc-title { font-size: 1.35rem; }
  .toc-tag { display: block; margin: 0.2rem 0 0; }

  table.users { font-size: 0.9rem; }
  table.users thead th, table.users tbody td { padding: 0.55rem 0.6rem; }
}

@media (min-width: 920px) {
  /* On wide screens, give the brand mark room to breathe */
  .brand-mark { font-size: 2rem; }
}

/* Print — should anyone ever actually print this */
@media print {
  body::before, body::after { display: none; }
  body { background: white; color: black; }
  .site-header, button { display: none; }
}
