/* Madlyn Jones Online Quilt Museum -- Palette A "Living Water"
   Contrast (WCAG 2.x) on linen #FAF8F3: ink 16.1, indigo 12.9, lapis 6.25,
   amethyst 7.66, pewter 4.76 (linen/white ONLY, never on lavender).
   Gold #9A7A2E is 3.81:1, so it is used for decorative lines only, never text. */

:root {
  --linen: #FAF8F3;
  --ink: #1C1B22;
  --indigo: #1E2A5A;
  --lapis: #2F5BA6;
  --amethyst: #5E3F8F;
  --lavender: #EFEAF6;
  --pewter: #6B6F76;   /* text only on linen or white */
  --gold: #9A7A2E;     /* lines only */
  --white: #FFFFFF;
  --danger: #8A1C1C;   /* error text; 8.2:1 on linen */

  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;

  --text-base: 18px;       /* body size required by the brief */
  --touch-min: 44px;       /* minimum tap target */
  --page-gutter: 16px;
  --page-max: 1200px;
  --radius: 4px;
  --frame-width: 8px;
}

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

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

body {
  margin: 0;
  background: var(--linen);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  overflow-wrap: anywhere; /* text always wraps, never overflows */
}

img, svg { max-width: 100%; height: auto; }

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--indigo);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 .5em;
}
h1 { font-size: clamp(2.25rem, 6vw, 3.75rem); }
h2 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h3 { font-size: 1.5rem; }
p { margin: 0 0 1em; max-width: 68ch; }

a { color: var(--lapis); text-underline-offset: 3px; }
a:hover { color: var(--indigo); }

:focus-visible {
  outline: 3px solid var(--lapis);
  outline-offset: 3px;
  border-radius: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--page-gutter); top: -100px;
  background: var(--white); color: var(--indigo); padding: .75rem 1rem;
  border: 2px solid var(--indigo); z-index: 100;
}
.skip-link:focus { top: 8px; }

.container { width: 100%; max-width: var(--page-max); margin-inline: auto; padding-inline: var(--page-gutter); }

/* ---------- Header / nav ---------- */
.site-header { background: var(--indigo); color: var(--linen); }
.site-header .container {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem 1.5rem; padding-block: .75rem;
}
.brand {
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; line-height: 1.1;
  color: var(--linen); text-decoration: none; min-height: var(--touch-min);
  display: inline-flex; align-items: center;
}
.brand:hover { color: var(--white); }
.nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; list-style: none; margin: 0; padding: 0; }
.nav a {
  color: var(--linen); text-decoration: none; min-height: var(--touch-min);
  display: inline-flex; align-items: center; padding-inline: .25rem;
  border-bottom: 3px solid transparent;
}
.nav a:hover { color: var(--white); border-bottom-color: var(--gold); }
.nav a[aria-current="page"] { border-bottom-color: var(--linen); font-weight: 600; }
.site-header :focus-visible { outline-color: var(--linen); }

/* ---------- Running-stitch wave divider ---------- */
.stitch {
  height: 20px; width: 100%; margin: 0; border: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='20' viewBox='0 0 96 20'%3E%3Cpath d='M0 10 Q24 0 48 10 T96 10' fill='none' stroke='%239A7A2E' stroke-width='2.5' stroke-linecap='round' stroke-dasharray='7 6'/%3E%3C/svg%3E") repeat-x center / 96px 20px;
}
.stitch-wrap { padding-block: 1.5rem; }

/* ---------- Sections ---------- */
.section { padding-block: 2.5rem; }
.band { background: var(--lavender); }
.eyebrow { font-size: .95rem; letter-spacing: .08em; text-transform: uppercase; color: var(--indigo); font-weight: 600; margin: 0 0 .5rem; }
.lead { font-size: 1.25rem; max-width: 60ch; }

.demo-banner {
  background: var(--lavender); color: var(--ink); border-bottom: 2px solid var(--gold);
  padding: .5rem var(--page-gutter); text-align: center; font-size: .95rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: var(--touch-min); min-width: var(--touch-min); padding: .6rem 1.25rem;
  font: inherit; font-weight: 600; line-height: 1.25;
  border: 2px solid var(--lapis); border-radius: var(--radius);
  background: var(--lapis); color: var(--white); text-decoration: none; cursor: pointer;
  transition: transform .15s ease, background-color .15s ease;
}
.btn:hover { background: var(--indigo); border-color: var(--indigo); color: var(--white); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: var(--linen); color: var(--lapis); }
.btn-secondary:hover { background: var(--lavender); color: var(--indigo); border-color: var(--indigo); }
.btn-danger { background: var(--linen); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--white); border-color: var(--danger); }
.btn-small { min-height: 36px; padding: .3rem .75rem; font-size: .95rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .6; cursor: not-allowed; transform: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; }

/* ---------- Hero ---------- */
.hero { display: grid; gap: 2rem; padding-block: 2.5rem; align-items: center; }
.hero-fact { font-weight: 600; color: var(--amethyst); }
.hero-art { margin: 0; }

/* ---------- Frames: status shown by colour AND a text label ---------- */
.frame {
  margin: 0; padding: var(--frame-width); background: var(--linen);
  border: var(--frame-width) solid var(--lapis);   /* on view online */
  outline: 1px solid var(--gold); outline-offset: -1px;
}
.frame img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: var(--lavender); }
.frame--on_loan  { border-color: var(--amethyst); }
.frame--archived { border-color: var(--pewter); }

/* Black-and-white "value view": same file, grayscale filter */
.bw .frame img, .frame.is-bw img { filter: grayscale(1); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; list-style: none; margin: 0; padding: 0; }
.card { display: flex; flex-direction: column; gap: .5rem; height: 100%; transition: transform .15s ease; }
.card:hover { transform: translateY(-2px); }
.card a.card-link { text-decoration: none; color: inherit; display: block; }
.card h3 { margin: .5rem 0 0; font-size: 1.5rem; }
.card h3 a { color: var(--indigo); text-decoration: none; }
.card h3 a:hover, .card h3 a:focus-visible { text-decoration: underline; }
.meta { margin: 0; color: var(--ink); font-size: 1rem; }
.piece-id { font-weight: 600; letter-spacing: .04em; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: .25rem 0 0; padding: 0; list-style: none; }

/* Status text labels. Pewter text appears only on linen cards, never on lavender. */
.status-label { font-size: 1rem; margin: 0; font-weight: 600; }
.status-label--on_loan  { color: var(--amethyst); }
.status-label--archived { color: var(--pewter); }

.badge {
  display: inline-flex; align-items: center; min-height: 28px; padding: .1rem .6rem;
  border: 1.5px solid var(--indigo); border-radius: 999px; background: var(--white);
  color: var(--indigo); font-size: .95rem; font-weight: 600; line-height: 1.2;
}
.badge--money { border-color: var(--amethyst); color: var(--amethyst); letter-spacing: .08em; }

/* ---------- Collection filters ---------- */
.filters { background: var(--lavender); border: 1px solid var(--gold); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.5rem; }
.filters-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field label, .field .label, legend { font-weight: 600; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.check { display: flex; align-items: center; gap: .6rem; min-height: var(--touch-min); }
.check input { width: 24px; height: 24px; accent-color: var(--lapis); flex: none; }
.key-note { margin: .75rem 0 0; font-size: 1rem; }
.result-count { font-weight: 600; margin: 0 0 1rem; }

/* ---------- Forms ---------- */
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="password"], input[type="date"], select, textarea {
  font: inherit; color: var(--ink); background: var(--white);
  width: 100%; max-width: 100%; min-height: var(--touch-min);
  padding: .5rem .75rem; border: 2px solid var(--pewter); border-radius: var(--radius);
}
textarea { min-height: 8rem; resize: vertical; }
input[readonly] { background: var(--lavender); }
.form-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.hint { font-size: 1rem; margin: 0; color: var(--ink); }
.req { color: var(--danger); font-weight: 700; }
.form-card { background: var(--white); border: 1px solid var(--gold); border-radius: var(--radius); padding: 1.25rem; }
fieldset { border: 1px solid var(--pewter); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0; min-width: 0; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; } /* honeypot, hidden from people */

.notice { padding: .9rem 1rem; border-radius: var(--radius); border: 2px solid var(--lapis); background: var(--white); margin: 0 0 1rem; }
.notice--error { border-color: var(--danger); color: var(--danger); }
.notice--ok { border-color: var(--amethyst); }

/* ---------- Piece page ---------- */
.piece { display: grid; gap: 2rem; padding-block: 2rem; }
.toggle { display: inline-flex; border: 2px solid var(--lapis); border-radius: var(--radius); overflow: hidden; margin-top: 1rem; }
.toggle button {
  font: inherit; font-weight: 600; min-height: var(--touch-min); padding: .4rem 1rem;
  border: 0; background: var(--linen); color: var(--lapis); cursor: pointer;
}
.toggle button + button { border-left: 2px solid var(--lapis); }
.toggle button[aria-pressed="true"] { background: var(--lapis); color: var(--white); }
.thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.thumbs button { padding: 2px; border: 2px solid var(--pewter); background: var(--linen); cursor: pointer; width: 72px; height: 72px; }
.thumbs button[aria-current="true"] { border-color: var(--lapis); border-width: 3px; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.specs { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 1rem 0 1.5rem; }
.specs dt { font-weight: 600; }
.specs dd { margin: 0; }
.breadcrumb { padding-top: 1.25rem; }
.verse { border-left: 4px solid var(--gold); padding: .5rem 0 .5rem 1.25rem; margin: 1.5rem 0; max-width: 60ch; }
.verse p { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.4; margin: 0 0 .5rem; }
.verse cite { font-style: normal; font-weight: 600; }
.placeholder-note { background: var(--lavender); border: 1.5px dashed var(--indigo); padding: .75rem 1rem; border-radius: var(--radius); }

/* ---------- Footer ---------- */
.site-footer { background: var(--indigo); color: var(--linen); padding-block: 2rem; margin-top: 3rem; font-size: 1rem; }
.site-footer a { color: var(--linen); }
.site-footer p { margin: 0 0 .5rem; max-width: none; }
.site-footer :focus-visible { outline-color: var(--linen); }

/* ---------- Admin ---------- */
.admin-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--gold); border-radius: var(--radius); background: var(--white); }
table { border-collapse: collapse; width: 100%; font-size: 1rem; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--lavender); vertical-align: middle; }
th { background: var(--lavender); color: var(--indigo); }
.switch { display: inline-flex; align-items: center; gap: .6rem; min-height: var(--touch-min); cursor: pointer; font-weight: 600; }
.switch input { width: 24px; height: 24px; accent-color: var(--amethyst); }
.state-draft { color: var(--ink); }
.admin-photos { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); list-style: none; margin: 0; padding: 0; }
.admin-photos li { border: 1px solid var(--pewter); padding: .5rem; background: var(--white); display: flex; flex-direction: column; gap: .4rem; }
.admin-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; }

/* ---------- Breakpoints (mobile first) ---------- */
@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .filters-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid.two { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  :root { --page-gutter: 32px; }
  .hero { grid-template-columns: 1.1fr .9fr; }
  .piece { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 3rem; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .filters-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 2rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .btn:hover, .btn:active, .card:hover { transform: none; }
}
