/* Dragons Market — Gig Harbor Dragons brand (Mark I.1). One stylesheet, no build step,
   no webfont, no external fetch. CSP is self-only: no inline styles anywhere.
   Every colour below is a token from docs/BRAND.md §1; nothing outside :root uses raw hex. */

:root {
  --gh-orange: #e77728;        /* primary / brand: banner gradient start, link accent, borders, hover fill */
  --gh-orange-ink: #b05617;    /* primary BUTTON fill with white text (5.0:1). BRAND's #c4601a measures 4.17:1 */
  --gh-gold: #f8c537;          /* banner gradient end, highlight */
  --gh-navy: #37384e;          /* top strip + footer background (dark surface) */
  --gh-ink: #4a4b65;           /* headings, prices */
  --gh-ink-2: #5a5b75;         /* readable body text, nav text, links */
  --gh-body: #737491;          /* meta / captions only (4.5:1 on white, 4.2:1 on bg) */
  --gh-muted: #9e9fb4;         /* tertiary: placeholders, ticks — never for text that must be read */
  --gh-bg: #f7f7fc;            /* page background */
  --gh-surface: #ffffff;       /* cards, nav bar */
  --gh-line: #e5e5ef;          /* hairlines / card borders */
  --gh-sky: #6a9bf4;           /* secondary action accent (decorative) */
  --gh-paddle: #5bb3e0;        /* paddle blue from the crest (decorative only) */
  --gh-dragon-red: #b01020;    /* SOLD banner, destructive */
  --gh-success: #16c995;       /* saved-state FILL (with navy text, 5.3:1) */
  --gh-success-ink: #0e7d5c;   /* "Free" price TEXT on white/bg (5.1:1); #16c995 as text is 2.1:1 */
  --gh-white: #ffffff;
  --gh-banner: linear-gradient(to right, var(--gh-orange) 0%, var(--gh-orange) 30%, var(--gh-gold) 100%);
  --gh-footer-text: rgba(255, 255, 255, 0.70);   /* ≈ #c3c3cb on navy, 6.6:1 (BRAND §2: "white 70%") */
  --gh-radius: 16px;
  --gh-radius-control: 8px;
  --gh-radius-pill: 999px;
  --gh-font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gh-weight-head: 600;
  --gh-weight-ui: 500;
  --gh-focus: 0 0 0 2px var(--gh-orange);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 16px/1.5 var(--gh-font);
  color: var(--gh-ink-2);
  background: var(--gh-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--gh-ink-2); text-decoration-color: var(--gh-orange); text-underline-offset: 2px; }
a:hover { color: var(--gh-orange-ink); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { color: var(--gh-ink); font-weight: var(--gh-weight-head); }
h1 { font-size: 1.6rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
code { font-size: 0.8em; background: var(--gh-bg); border: 1px solid var(--gh-line); padding: 0.1em 0.3em; border-radius: 4px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); border: 0;
}

/* ---- top strip (navy) ---- */
.topbar { background: var(--gh-navy); color: var(--gh-white); font-size: 0.85rem; font-weight: var(--gh-weight-ui); }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 1rem; min-height: 36px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.topbar-org { color: var(--gh-footer-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-org strong { color: var(--gh-white); font-weight: var(--gh-weight-head); }
.topbar-links { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar-links a { color: var(--gh-white); text-decoration: none; }
.topbar-links a:hover { color: var(--gh-gold); }
.topbar-user { color: var(--gh-footer-text); }
.topbar .link-button { color: var(--gh-white); }
.topbar .link-button:hover { color: var(--gh-gold); }
.badge {
  display: inline-block; min-width: 1.4em; padding: 0 0.4em; border-radius: var(--gh-radius-pill);
  background: var(--gh-orange-ink); color: var(--gh-white); font-size: 0.75rem; font-weight: 700; text-align: center; line-height: 1.5;
}

/* ---- nav (white) ---- */
.nav { background: var(--gh-surface); border-bottom: 1px solid var(--gh-line); position: sticky; top: 0; z-index: 10; }
.nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 0.75rem 1rem; min-height: 64px;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { height: 40px; width: auto; }
.nav-search { display: flex; flex: 1 1 260px; gap: 0.4rem; min-width: 200px; }
.nav-search input { flex: 1; border-radius: var(--gh-radius-pill); padding-left: 1rem; }
.nav-actions { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.inline-form { display: inline; }
.link-button {
  background: none; border: 0; padding: 0; color: var(--gh-ink-2); font: inherit; font-weight: var(--gh-weight-ui); cursor: pointer;
}
.link-button:hover { color: var(--gh-orange-ink); text-decoration: underline; }

/* ---- flash ---- */
.flash {
  max-width: 1200px; margin: 0.75rem auto 0; padding: 0.6rem 1rem; border-radius: var(--gh-radius-control);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: var(--gh-surface); color: var(--gh-ink); border: 1px solid var(--gh-success-ink); border-left-width: 6px;
}
.flash-error { border-color: var(--gh-dragon-red); }
.flash-close { background: none; border: 0; font-size: 1.3rem; line-height: 1; cursor: pointer; color: inherit; }

/* ---- layout ---- */
.main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 1rem; }

/* ---- page banner (orange → gold) ---- */
.banner {
  background: var(--gh-banner); border-radius: var(--gh-radius); padding: 1.25rem 1.5rem; margin-bottom: 1rem;
  min-height: 96px; display: flex; flex-direction: column; justify-content: center; gap: 0.2rem;
}
/* Banner text is navy, not the white BRAND §2 names: white on the gold end of the gradient
   is ~1.6:1. Navy measures 3.84:1 on the orange stop and 7.09:1 on gold; both lines are
   WCAG "large text" (h1 32px; subtitle 19.2px desktop / 18.72px mobile at weight 700 ≥ 14pt bold) so 3.0:1 applies. */
.banner h1 { color: var(--gh-navy); font-size: 2rem; line-height: 1.2; margin: 0; }
.banner-subtitle { color: var(--gh-navy); font-size: 1.2rem; font-weight: 700; margin: 0; }

/* ---- footer (navy, 3 columns) ---- */
.footer { background: var(--gh-navy); color: var(--gh-footer-text); font-size: 0.9rem; margin-top: 2rem; }
.footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 2rem 1rem 1rem;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem;
}
.footer-col h2 { color: var(--gh-white); font-size: 0.95rem; margin-bottom: 0.4rem; }
.footer-col p { margin: 0.25rem 0; }
.footer-org { display: flex; align-items: center; gap: 0.75rem; }
.footer-org img { height: 72px; width: auto; background: var(--gh-white); border-radius: var(--gh-radius-control); padding: 4px; }
.footer-org strong { color: var(--gh-white); display: block; }
.footer-links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.footer a { color: var(--gh-white); text-decoration-color: var(--gh-gold); }
.footer a:hover { color: var(--gh-gold); }
.footer-bottom {
  max-width: 1200px; margin: 0 auto; padding: 0.75rem 1rem 1.25rem; border-top: 1px solid var(--gh-ink-2);
  font-size: 0.8rem; color: var(--gh-footer-text);
}

/* ---- buttons & forms ---- */
button, .btn {
  display: inline-block; font: inherit; font-weight: var(--gh-weight-ui); font-size: 0.95rem;
  padding: 0.45rem 0.9rem; border-radius: var(--gh-radius-control); border: 1px solid var(--gh-navy);
  background: var(--gh-surface); color: var(--gh-navy); cursor: pointer; text-decoration: none; line-height: 1.3;
}
button:hover, .btn:hover { background: var(--gh-navy); color: var(--gh-white); }
.btn-primary, button.btn-primary { background: var(--gh-orange-ink); border-color: var(--gh-orange-ink); color: var(--gh-white); }
.btn-primary:hover, button.btn-primary:hover { background: var(--gh-orange); border-color: var(--gh-orange); color: var(--gh-white); }
.btn-danger, button.btn-danger { color: var(--gh-dragon-red); border-color: var(--gh-dragon-red); background: var(--gh-surface); }
.btn-danger:hover, button.btn-danger:hover { background: var(--gh-dragon-red); color: var(--gh-white); }
.btn-small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="file"], select, textarea {
  font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--gh-line); border-radius: var(--gh-radius-control);
  background: var(--gh-surface); color: var(--gh-ink); width: 100%; max-width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--gh-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gh-orange); box-shadow: var(--gh-focus); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: var(--gh-focus); border-radius: var(--gh-radius-control); }
textarea { resize: vertical; }
label { font-weight: var(--gh-weight-head); font-size: 0.9rem; color: var(--gh-ink); }

.form-page { max-width: 760px; }
.form-narrow { max-width: 440px; }
.form-intro { color: var(--gh-ink-2); margin: -0.25rem 0 1rem; }
.form-subtitle { color: var(--gh-ink-2); font-size: 1.05rem; margin: -0.5rem 0 1rem; }
.field { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row .field { flex: 1 1 160px; }
.field-row .field-narrow { flex: 0 0 110px; }
.field-hint { margin: 0; color: var(--gh-body); font-size: 0.85rem; }
.field-error, .form-error { margin: 0; color: var(--gh-dragon-red); font-size: 0.9rem; }
.form-error { padding: 0.5rem 0.75rem; background: var(--gh-surface); border: 1px solid var(--gh-dragon-red); border-radius: var(--gh-radius-control); margin-bottom: 1rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--gh-dragon-red); }
.form-footnote { color: var(--gh-body); font-size: 0.9rem; }

/* ---- browse grid ---- */
.filter-bar {
  display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end;
  background: var(--gh-surface); border: 1px solid var(--gh-line); border-radius: var(--gh-radius); padding: 0.9rem 1rem; margin-bottom: 1rem;
}
.filter-bar label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; color: var(--gh-body); }
.filter-bar input, .filter-bar select { width: auto; min-width: 7rem; }
.filter-bar input[size="7"] { min-width: 5.5rem; }
.filter-reset { align-self: center; font-size: 0.9rem; }
.results-line { color: var(--gh-body); margin: 0 0 0.75rem; }

.empty {
  color: var(--gh-ink-2); padding: 3rem 1rem; text-align: center;
  background: var(--gh-surface) url("/img/brand/wave.svg") repeat-x center bottom; background-size: 160px auto;
  border: 1px solid var(--gh-line); border-radius: var(--gh-radius);
}

.grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.listing-card {
  background: var(--gh-surface); border: 1px solid var(--gh-line); border-radius: var(--gh-radius); overflow: hidden;
  display: flex; flex-direction: column; position: relative;
}
.listing-card:focus-within { outline: 2px solid var(--gh-orange); outline-offset: 0; }
.card-media { display: block; aspect-ratio: 4 / 3; background: var(--gh-bg); overflow: hidden; position: relative; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media img.placeholder { object-fit: cover; }
.sold-tag {
  position: absolute; top: 0.5rem; left: 0.5rem; background: var(--gh-dragon-red); color: var(--gh-white);
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; padding: 0.15rem 0.45rem; border-radius: 4px;
}
.is-sold .card-media img { filter: grayscale(0.6); opacity: 0.85; }
.card-body { padding: 0.6rem 0.75rem 0.75rem; display: flex; flex-direction: column; gap: 0.15rem; }
.card-price { font-weight: var(--gh-weight-head); color: var(--gh-ink); }
.card-price.is-free { color: var(--gh-success-ink); }
.card-title {
  color: var(--gh-ink); text-decoration: none; font-size: 0.95rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-title:hover { text-decoration: underline; }
.card-meta { color: var(--gh-body); font-size: 0.8125rem; }
.card-save { position: absolute; top: 0.4rem; right: 0.4rem; }
.save-button {
  padding: 0.25rem 0.6rem; font-size: 0.8rem; border-radius: var(--gh-radius-pill);
  background: var(--gh-surface); color: var(--gh-navy); border-color: var(--gh-navy);
}
.save-button:hover { background: var(--gh-navy); color: var(--gh-white); }
.save-button.is-saved { background: var(--gh-success); border-color: var(--gh-success); color: var(--gh-navy); }
.save-button.is-saved:hover { background: var(--gh-success-ink); border-color: var(--gh-success-ink); color: var(--gh-white); }

.pagination { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 1.5rem 0; color: var(--gh-body); }

/* ---- listing detail ---- */
.sold-banner {
  background: var(--gh-dragon-red); color: var(--gh-white); font-weight: var(--gh-weight-head); letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.5rem 1rem; border-radius: var(--gh-radius-control); margin-bottom: 1rem; text-align: center;
}
.detail-layout { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); }
@media (max-width: 800px) { .detail-layout { grid-template-columns: 1fr; } }
.gallery { display: flex; flex-direction: column; gap: 0.75rem; }
.gallery-item { margin: 0; background: var(--gh-bg); border: 1px solid var(--gh-line); border-radius: var(--gh-radius); overflow: hidden; }
.gallery-item img { width: 100%; height: auto; }
.gallery-main.placeholder { border: 1px solid var(--gh-line); border-radius: var(--gh-radius); width: 100%; }
.detail-side { display: flex; flex-direction: column; gap: 1rem; }
.detail-title { font-size: 1.5rem; margin: 0; }
.detail-price { font-size: 1.6rem; font-weight: var(--gh-weight-head); color: var(--gh-ink); }
.detail-price.is-free { color: var(--gh-success-ink); }
.detail-facts { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0; font-size: 0.95rem; }
.detail-facts dt { color: var(--gh-body); }
.detail-facts dd { margin: 0; color: var(--gh-ink); }
.seller-card, .owner-actions, .message-seller {
  background: var(--gh-surface); border: 1px solid var(--gh-line); border-radius: var(--gh-radius); padding: 0.9rem 1rem;
}
.seller-name { font-weight: var(--gh-weight-head); text-decoration: none; color: var(--gh-ink); }
.seller-meta { color: var(--gh-body); font-size: 0.85rem; }
.owner-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.owner-actions h2 { flex-basis: 100%; }
.message-seller textarea { margin-bottom: 0.5rem; }
.detail-description { margin-top: 1.5rem; background: var(--gh-surface); border: 1px solid var(--gh-line); border-radius: var(--gh-radius); padding: 1rem; }
.description-text { white-space: pre-line; margin: 0; color: var(--gh-ink-2); }

/* ---- edit ---- */
.edit-images { margin-top: 2rem; }
.edit-gallery { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.edit-gallery-item { background: var(--gh-surface); border: 1px solid var(--gh-line); border-radius: var(--gh-radius); overflow: hidden; }
.edit-gallery-item img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.edit-gallery-meta { padding: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.8rem; }
.photo-index { font-weight: 700; background: var(--gh-orange-ink); color: var(--gh-white); border-radius: var(--gh-radius-pill); width: 1.5em; height: 1.5em; display: inline-flex; align-items: center; justify-content: center; }
.photo-id { word-break: break-all; font-size: 0.65rem; }
.image-preview { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.image-preview img { width: 90px; height: 68px; object-fit: cover; border-radius: var(--gh-radius-control); border: 1px solid var(--gh-line); }
.image-preview .preview-note { color: var(--gh-body); font-size: 0.85rem; flex-basis: 100%; }
.image-preview .preview-warn { color: var(--gh-dragon-red); }

/* ---- profile ---- */
.profile-header { margin-bottom: 1rem; }
.profile-meta { color: var(--gh-body); margin: 0; }

/* ---- inbox ---- */
.thread-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.thread-row a {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "who age" "listing listing" "preview preview";
  gap: 0.1rem 1rem; padding: 0.75rem 1rem; background: var(--gh-surface); border: 1px solid var(--gh-line);
  border-radius: var(--gh-radius); text-decoration: none; color: var(--gh-ink);
}
.thread-row a:hover { border-color: var(--gh-orange); color: var(--gh-ink); }
.thread-row.is-unread a { border-left: 4px solid var(--gh-orange); }
.thread-who { grid-area: who; font-weight: var(--gh-weight-head); }
.thread-age { grid-area: age; color: var(--gh-body); font-size: 0.85rem; }
.thread-listing { grid-area: listing; color: var(--gh-orange-ink); font-size: 0.9rem; }
.thread-preview { grid-area: preview; color: var(--gh-body); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thread-page { max-width: 760px; }
.thread-header h1 { margin-bottom: 0.2rem; }
.thread-about { color: var(--gh-body); margin: 0 0 1rem; }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.message { max-width: 80%; align-self: flex-start; }
.message.is-mine { align-self: flex-end; }
.message-body {
  background: var(--gh-surface); border: 1px solid var(--gh-line); border-radius: 14px; padding: 0.55rem 0.85rem;
  white-space: pre-line; word-wrap: break-word; color: var(--gh-ink);
}
.message.is-mine .message-body { background: var(--gh-navy); color: var(--gh-white); border-color: var(--gh-navy); }
.message-meta { color: var(--gh-body); font-size: 0.75rem; margin-top: 0.15rem; padding: 0 0.4rem; }
.message.is-mine .message-meta { text-align: right; }
.reply-form .field { margin-bottom: 0.5rem; }

/* ---- errors ---- */
.error-page {
  text-align: center; padding: 3rem 1rem 4rem; color: var(--gh-ink-2);
  background: var(--gh-surface) url("/img/brand/wave.svg") repeat-x center bottom; background-size: 160px auto;
  border: 1px solid var(--gh-line); border-radius: var(--gh-radius);
}
.error-page h1 { font-size: 2rem; }

/* ---- mobile ---- */
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .brand img { height: 28px; }
  .topbar-inner { flex-wrap: nowrap; min-height: 32px; font-size: 0.78rem; }
  .topbar-links { gap: 0.6rem; }
  .topbar-user { display: none; }
  .nav-inner { min-height: 56px; }
  .banner h1 { font-size: 1.5rem; }
  .banner-subtitle { font-size: 1.17rem; } /* 18.72px — stays ≥ 18.67px so "large text" 3.0:1 still applies */
  .footer-inner { grid-template-columns: 1fr; }
}
