/* Hyperborean Collection --- a cold, high-contrast archive. */

:root {
  --bg:        #070a10;
  --bg-deep:   #04060b;
  --surface:   #0e1420;
  --surface-2: #141c2b;
  --line:      #1e2839;
  --line-soft: #172032;
  --text:      #e2e9f4;
  --muted:     #8a9ab4;
  --dim:       #5f6d84;
  --ice:       #7fd4e8;
  --ice-deep:  #3f93ad;
  --gold:      #d9b26a;
  --danger:    #e2645f;
  --ok:        #6fce9f;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius: 3px;
  --shadow: 0 18px 50px -24px rgba(0, 0, 0, .9);
  --wrap: 1240px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  /* A faint aurora over the deep field. */
  background-image:
    radial-gradient(1100px 520px at 12% -10%, rgba(63, 147, 173, .16), transparent 65%),
    radial-gradient(900px 460px at 92% 4%, rgba(127, 212, 232, .08), transparent 60%);
  background-attachment: fixed;
}

a { color: var(--ice); text-decoration: none; }
a:hover { color: #a9e4f2; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 4vw, 2.9rem); letter-spacing: -.01em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.eyebrow {
  font-family: var(--sans);
  font-size: .68rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 .9rem;
}
.muted { color: var(--muted); }
.dim { color: var(--dim); font-size: .85rem; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }

/* --- Header --------------------------------------------------------------- */

.masthead {
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 16, .86);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 50;
}
.masthead .wrap {
  display: flex; align-items: center; gap: 28px;
  min-height: 68px; flex-wrap: wrap;
}
.brand {
  font-family: var(--serif);
  font-size: 1.22rem;
  letter-spacing: .04em;
  color: var(--text);
  white-space: nowrap;
  display: flex; align-items: center; gap: 10px;
}
.brand:hover { color: var(--text); }
.brand-mark { width: 30px; height: 30px; flex: none; display: block; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a {
  color: var(--muted);
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--ice); }

.searchbar { display: flex; align-items: center; gap: 8px; }

/* --- Forms & buttons ------------------------------------------------------ */

input[type=text], input[type=password], input[type=search], input[type=number],
textarea, select {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 13px;
  border-radius: var(--radius);
  font: inherit;
  font-size: .93rem;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ice-deep);
  box-shadow: 0 0 0 3px rgba(63, 147, 173, .16);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
label {
  display: block;
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 6px;
}
.field + .field { margin-top: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 20px;
  border-radius: var(--radius);
  font: inherit;
  font-size: .82rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.btn:hover { background: #1a2434; border-color: #2b3850; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, #2a6c81, #1d4f60);
  border-color: #367f97; color: #eaf7fb;
}
.btn-primary:hover { background: linear-gradient(180deg, #327e96, #235c70); }
.btn-gold {
  background: linear-gradient(180deg, #c9a25c, #a8843f);
  border-color: #d9b26a; color: #17120a; font-weight: 600;
}
.btn-gold:hover { background: linear-gradient(180deg, #d9b26a, #b8924b); }
.btn-ghost { background: transparent; }
.btn-danger { border-color: #5a2b2b; color: #eda4a1; background: transparent; }
.btn-danger:hover { background: #2a1414; border-color: #7a3a38; }
.btn-sm { padding: 6px 12px; font-size: .7rem; }
.btn-block { width: 100%; }

.notice {
  border: 1px solid var(--line);
  border-left: 2px solid var(--ice-deep);
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .9rem;
}
.notice-error { border-left-color: var(--danger); color: #f0bdba; }
.notice-ok { border-left-color: var(--ok); color: #b8e9ce; }
.notice-warn { border-left-color: var(--gold); color: #ecd6a8; }

/* --- Landing -------------------------------------------------------------- */

.gate {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 24px;
  text-align: center;
}
.gate-mark {
  display: block; margin: 0 auto 20px;
  width: clamp(104px, 24vw, 148px); height: auto;
}
.gate h1 {
  font-size: clamp(2.4rem, 6vw, 4.1rem);
  letter-spacing: .01em;
  margin-bottom: .35em;
  background: linear-gradient(180deg, #f2f7fd 15%, #9fb6cf 115%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.gate-lede {
  color: var(--muted); max-width: 46ch; margin: 0 auto 2.6rem;
  font-family: var(--serif); font-size: 1.12rem; line-height: 1.65;
}
.gate-rule {
  width: 100%; max-width: 420px; height: 1px; margin: 0 auto 2.4rem;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}
.gate-panels {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(288px, 1fr));
  gap: 20px; width: 100%; max-width: 780px; text-align: left;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 1.22rem; margin-bottom: .35em; }
.panel p { color: var(--muted); font-size: .9rem; margin: 0 0 1.3rem; }
.price {
  font-family: var(--serif); font-size: 2.5rem; color: var(--gold);
  line-height: 1; margin-bottom: .1em;
}
.price small {
  display: block; font-family: var(--sans); font-size: .68rem;
  letter-spacing: .2em; text-transform: uppercase; color: var(--dim);
  margin-top: 10px;
}
.code-input {
  font-family: var(--mono); letter-spacing: .16em; text-transform: uppercase;
  text-align: center; font-size: 1rem;
}
.gate-foot { margin-top: 2.8rem; color: var(--dim); font-size: .78rem; max-width: 52ch; }

/* --- Payment -------------------------------------------------------------- */

.pay-grid {
  display: grid; grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 34px; align-items: start;
}
@media (max-width: 720px) { .pay-grid { grid-template-columns: 1fr; } }

.qr {
  background: #fff0; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; background-color: #0b1018;
}
.qr svg { width: 100%; height: auto; display: block; }

.pay-field { margin-bottom: 20px; }
.pay-value {
  font-family: var(--mono); font-size: .84rem; word-break: break-all;
  background: var(--bg-deep); border: 1px solid var(--line);
  padding: 12px 14px; border-radius: var(--radius); line-height: 1.55;
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
}
.pay-amount { font-size: 1.28rem; color: var(--gold); letter-spacing: .01em; }
.copy {
  background: none; border: 1px solid var(--line); color: var(--muted);
  font: inherit; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 9px; border-radius: var(--radius); cursor: pointer; flex: none;
}
.copy:hover { color: var(--text); border-color: var(--ice-deep); }

.status-line {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 16px 18px; margin-bottom: 22px;
}
.pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 0 0 rgba(217, 178, 106, .6);
  animation: pulse 2s infinite; flex: none;
}
.pulse.ok { background: var(--ok); animation: none; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(217, 178, 106, .55); }
  70%  { box-shadow: 0 0 0 12px rgba(217, 178, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 178, 106, 0); }
}

.code-reveal {
  font-family: var(--mono); font-size: clamp(1rem, 3.2vw, 1.5rem);
  letter-spacing: .1em; color: var(--gold); text-align: center;
  background: var(--bg-deep); border: 1px dashed #4a3d22;
  padding: 22px; border-radius: var(--radius); margin: 18px 0; word-break: break-all;
}

/* --- Catalogue ------------------------------------------------------------ */

.page-head {
  padding: 40px 0 26px; border-bottom: 1px solid var(--line-soft); margin-bottom: 30px;
}
.filters {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 20px;
}
.filters input[type=search] { max-width: 320px; }
.filters select { width: auto; min-width: 140px; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  font-size: .72rem; color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); padding: 4px 10px; border-radius: 100px;
  letter-spacing: .04em; white-space: nowrap;
}
a.chip:hover { color: var(--ice); border-color: var(--ice-deep); }
.chip.active { color: var(--ice); border-color: var(--ice-deep); background: #10202a; }

.grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .18s ease, border-color .18s, box-shadow .18s;
}
.card:hover {
  transform: translateY(-3px); border-color: #2c3d55; box-shadow: var(--shadow);
}
.card-thumb {
  position: relative; aspect-ratio: 16 / 10; background: var(--bg-deep);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb.book { aspect-ratio: 3 / 4; }
.placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  gap: 8px; color: var(--dim);
  background:
    linear-gradient(140deg, #0d1420, #101a28 55%, #0b111b),
    var(--bg-deep);
}
.placeholder .ext {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .2em; text-transform: uppercase;
}
.placeholder .sigil { font-size: 1.9rem; opacity: .5; }
.badge {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(4, 6, 11, .82); color: var(--text);
  font-family: var(--mono); font-size: .68rem; padding: 3px 7px;
  border-radius: 2px; letter-spacing: .04em;
}
.badge-kind { left: 8px; right: auto; color: var(--ice); text-transform: uppercase; }
.card-body { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-title {
  font-family: var(--serif); font-size: 1rem; line-height: 1.3; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card:hover .card-title { color: #fff; }
.card-meta {
  margin-top: auto; display: flex; gap: 10px; align-items: center;
  color: var(--dim); font-size: .72rem; letter-spacing: .04em;
}

.empty {
  text-align: center; padding: 90px 20px; color: var(--dim);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty .sigil { font-size: 2.6rem; opacity: .35; display: block; margin-bottom: 14px; }

.pager { display: flex; gap: 8px; justify-content: center; align-items: center; padding: 40px 0; }

/* --- Item detail ---------------------------------------------------------- */

.item-layout { display: grid; grid-template-columns: 1fr 320px; gap: 40px; align-items: start; }
@media (max-width: 900px) { .item-layout { grid-template-columns: 1fr; } }

.viewer {
  background: var(--bg-deep); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.viewer video, .viewer audio, .viewer img { display: block; width: 100%; }
.viewer video { max-height: 76vh; background: #000; }
.viewer img { max-height: 80vh; object-fit: contain; margin: 0 auto; }
.viewer audio { padding: 20px; }
.viewer iframe { display: block; width: 100%; height: 82vh; border: 0; background: #1a1a1a; }

.meta-list { border-top: 1px solid var(--line-soft); }
.meta-row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft); font-size: .88rem;
}
.meta-row dt { color: var(--dim); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; }
.meta-row dd { margin: 0; text-align: right; color: var(--muted); font-family: var(--mono); font-size: .82rem; }

.prose { font-family: var(--serif); font-size: 1.04rem; line-height: 1.7; color: #c6d2e2; white-space: pre-wrap; }

/* --- Tables (admin) ------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
  text-align: left; font-size: .68rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--dim); font-weight: 500; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:hover td { background: rgba(20, 28, 43, .5); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

.tag-pill {
  display: inline-block; font-size: .7rem; color: var(--muted);
  border: 1px solid var(--line); padding: 2px 7px; border-radius: 100px; margin: 2px 3px 2px 0;
}

/* --- Admin chrome --------------------------------------------------------- */

.admin-bar {
  background: var(--bg-deep); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.admin-bar .wrap { display: flex; align-items: center; gap: 6px; min-height: 56px; flex-wrap: wrap; }
.admin-bar .brand { font-size: 1rem; margin-right: 16px; }
.admin-bar .brand-mark { width: 24px; height: 24px; }
.admin-bar a.tab {
  color: var(--muted); font-size: .74rem; letter-spacing: .14em; text-transform: uppercase;
  padding: 8px 13px; border-radius: var(--radius);
}
.admin-bar a.tab:hover { color: var(--text); background: var(--surface); }
.admin-bar a.tab.active { color: var(--bg); background: var(--ice); }

.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.stat .n { font-family: var(--serif); font-size: 1.9rem; line-height: 1; color: var(--text); }
.stat .k {
  font-size: .66rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--dim); margin-top: 8px;
}
.stat.alert .n { color: var(--gold); }

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 56px 24px; text-align: center; color: var(--muted);
  transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone:hover, .dropzone.over { border-color: var(--ice-deep); background: rgba(63, 147, 173, .07); }
.dropzone .sigil { font-size: 2.4rem; opacity: .5; display: block; margin-bottom: 12px; }

.queue { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.qrow {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.qrow-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.qrow-name { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qrow-state { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); flex: none; }
.qrow-state.done { color: var(--ok); }
.qrow-state.error { color: var(--danger); }
.bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--ice-deep); transition: width .2s; }
.qrow-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
@media (max-width: 640px) { .qrow-fields { grid-template-columns: 1fr; } }

.modal-back {
  position: fixed; inset: 0; background: rgba(4, 6, 11, .82);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; max-width: 560px; width: 100%; box-shadow: var(--shadow);
  max-height: 88vh; overflow-y: auto;
}
[hidden] { display: none !important; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-end { margin-left: auto; }
.section-block { margin-bottom: 40px; }
.footer {
  border-top: 1px solid var(--line-soft); margin-top: 70px; padding: 30px 0 50px;
  color: var(--dim); font-size: .78rem;
}
