/* Visual language is *inspired by* the look of a Magic card back - deep warm
   browns, an aged-parchment cream, gold filigree edges and a serif display face.
   Nothing here reproduces any Wizards of the Coast artwork, mark or symbol; the
   ornament is all CSS gradients and rotated squares. */

:root {
  color-scheme: dark;

  --ink: #0d0805;
  --bg: #170f09;
  --bg-deep: #0b0704;
  --panel: #241811;
  --panel-hi: #2f2016;
  --panel-sunken: #1a110b;

  --gold: #b8924a;
  --gold-bright: #e3c380;
  --gold-dim: #6d5630;

  --parchment: #ece0c8;
  --muted: #a08e73;
  --danger: #d9695a;
  --success: #8fb573;

  --frame: 0 0 0 1px var(--gold-dim), 0 0 0 4px var(--ink), 0 10px 28px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color: var(--parchment);
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, #3a2617 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 50% 110%, #2a1a10 0%, transparent 65%),
    var(--bg-deep);
  background-attachment: fixed;
  min-height: 100vh;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

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

header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0 6px;
  color: var(--gold-bright);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

/* Rule with a diamond finial, echoing a card frame's centre ornament. */
header h1::after {
  content: "";
  display: block;
  width: min(320px, 70%);
  height: 1px;
  margin: 14px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  position: relative;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
  font-style: italic;
}

.subtitle::before {
  content: "";
  display: block;
  width: 9px;
  height: 9px;
  margin: -5px auto 10px;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: 0 0 0 3px var(--bg-deep);
}

/* --- Panels ---------------------------------------------------------------- */

.card {
  position: relative;
  background: linear-gradient(160deg, var(--panel-hi), var(--panel) 55%, #1e140d);
  border: 1px solid var(--gold-dim);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--frame);
}

/* Inner hairline, the way a card's border sits inside its bevel. */
.card::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(184, 146, 74, 0.22);
  border-radius: 9px;
  pointer-events: none;
}

.card > * {
  position: relative;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold-bright);
  letter-spacing: 0.03em;
}

/* --- Form controls --------------------------------------------------------- */

.source-toggle {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 0.95rem;
}

.source-toggle label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--gold);
}

.source-input input[type="file"],
.source-input textarea,
.field input[type="text"],
.add-row input[type="text"],
.add-row select {
  width: 100%;
  padding: 11px 13px;
  border-radius: 7px;
  border: 1px solid var(--gold-dim);
  background: var(--panel-sunken);
  color: var(--parchment);
  font-size: 0.95rem;
  font-family: inherit;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.source-input textarea {
  resize: vertical;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.6;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

::placeholder {
  color: #7a6950;
}

/* --- Tabs ------------------------------------------------------------------ */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--gold-dim);
}

.tab-btn {
  background: none;
  border: none;
  padding: 9px 16px;
  margin-bottom: -1px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  letter-spacing: 0.02em;
}

.tab-btn:hover {
  color: var(--parchment);
}

.tab-btn.active {
  color: var(--gold-bright);
  border-bottom-color: var(--gold);
  font-weight: 600;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* --- Text ------------------------------------------------------------------ */

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.hint-inline {
  color: var(--muted);
  font-weight: normal;
  font-size: 0.85rem;
  font-style: italic;
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gold-bright);
}

.field-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--gold-bright);
  letter-spacing: 0.02em;
}

/* --- Preference blocks ----------------------------------------------------- */

.pref-block {
  border: 1px solid rgba(184, 146, 74, 0.3);
  border-radius: 10px;
  padding: 15px 17px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.18);
}

.pref-block.disabled .pref-body,
.pref-block.disabled .hint {
  opacity: 0.4;
}

.pref-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.pref-block .hint {
  margin: 5px 0 12px 25px;
}

.add-row {
  display: flex;
  gap: 8px;
}

.add-row input[type="text"],
.add-row select {
  flex: 1;
  min-width: 0;
}

.add-btn,
.ghost-btn {
  padding: 10px 17px;
  border-radius: 7px;
  border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, #32231800, rgba(0, 0, 0, 0.3));
  color: var(--gold-bright);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.add-btn:hover:not(:disabled),
.ghost-btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(184, 146, 74, 0.14);
}

.add-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pref-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pref-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 1px solid rgba(184, 146, 74, 0.28);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(184, 146, 74, 0.08), rgba(0, 0, 0, 0.25));
  font-size: 0.9rem;
}

.pref-item.dragging {
  opacity: 0.35;
}

.pref-handle {
  color: var(--gold-dim);
  cursor: grab;
}

.pref-rank {
  color: var(--gold);
  /* The serif display face defaults to old-style figures, which drop numerals
     below the baseline and read as misaligned next to the label. */
  font-variant-numeric: lining-nums tabular-nums;
  font-weight: 600;
}

.pref-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pref-note {
  color: var(--muted);
  font-size: 0.76rem;
  font-style: italic;
  white-space: nowrap;
}

.pref-action {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  padding: 5px 7px;
  border-radius: 5px;
  cursor: pointer;
}

.pref-action:hover:not(:disabled) {
  color: var(--gold-bright);
  background: rgba(184, 146, 74, 0.16);
}

.pref-action:disabled {
  opacity: 0.25;
  cursor: default;
}

.empty-hint {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
  margin: 10px 0 0;
}

/* --- Action + activity ----------------------------------------------------- */

.action-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#generateBtn {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 45%, #8f6f36 100%);
  color: #1a1209;
  border: 1px solid var(--gold-bright);
  padding: 13px 30px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 3px 0 #5c4722, 0 6px 16px rgba(0, 0, 0, 0.5);
}

#generateBtn:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 100%);
}

#generateBtn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #5c4722, 0 3px 10px rgba(0, 0, 0, 0.5);
}

#generateBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.status {
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.2em;
}

.status.error {
  color: var(--danger);
}

.activity {
  border: 1px solid rgba(184, 146, 74, 0.3);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.3);
  padding: 14px;
}

.progress-track {
  height: 9px;
  border-radius: 999px;
  background: var(--panel-sunken);
  border: 1px solid var(--gold-dim);
  overflow: hidden;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #8f6f36, var(--gold-bright));
  transition: width 0.35s ease;
}

.progress-caption {
  margin-top: 7px;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
  text-align: right;
}

.activity-log {
  list-style: none;
  margin: 12px 0 0;
  padding: 0 4px 0 0;
  max-height: 260px;
  overflow-y: auto;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.79rem;
  line-height: 1.75;
  color: var(--muted);
}

.activity-log li {
  padding: 1px 0;
  border-bottom: 1px solid rgba(184, 146, 74, 0.08);
  overflow-wrap: anywhere;
}

.activity-log li:last-child {
  color: var(--parchment);
  border-bottom: none;
}

.activity-log li.miss {
  color: var(--danger);
}

.activity-log::-webkit-scrollbar {
  width: 8px;
}

.activity-log::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 999px;
}

/* --- Footer ---------------------------------------------------------------- */

.version-tag {
  margin-top: 28px;
  text-align: center;
  font-size: 0.75rem;
  color: #6a5a44;
  letter-spacing: 0.06em;
  font-variant-numeric: lining-nums;
}

.version-sep {
  opacity: 0.5;
  margin: 0 2px;
}

/* An image built without deploy.sh carries no commit, so it can't be checked
   against the repo - say so rather than showing a version that might be stale. */
.version-warn {
  color: #9a7a3a;
  font-style: italic;
}
