/* fantasy.css -- the shared look of the out-of-game pages (login,
   character select, character create), built from the UI art in
   images/ui/. Loaded after theme.css.

   Every size in the frame is a fraction of --fw (the frame's width),
   so the art pieces stay lined up at any screen size. The numbers
   come from pixel positions in the original art sheet. */
:root {
  --fw: clamp(340px, 36vw, 500px);
  --parchment: #e6d2a4;
  --parchment-dark: #c9ad7c;
  --ink: #3b2418;
  --btn-font: "PT Sans Narrow", "Arial Narrow", sans-serif;
  --body-font: "Alegreya Sans", "Segoe UI", sans-serif;
  --title-font: "Cinzel", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text-primary);
  font-family: var(--body-font);
}

body {
  min-height: 100vh;
  background: #0c0a09 url("../images/background.jpg") center bottom / cover no-repeat fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0.1), rgba(0,0,0,0.55));
  pointer-events: none;
  z-index: 0;
}

img { user-select: none; -webkit-user-drag: none; }

.layout {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: calc(var(--fw) * 0.06);
  padding: 0 16px 48px;
  margin-top: calc(var(--fw) * 0.06);
}

/* ===== Centre column: title plaque + gear + login frame ===== */
.frame-col {
  width: var(--fw);
  flex: none;
  position: relative;
  filter: drop-shadow(0 12px 18px rgba(0,0,0,0.6));
}

.frame-header {
  display: block;
  width: 128.28%;          /* header art is wider than the frame (plaque) */
  margin-left: -14.035%;
  height: auto;
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.frame-body {
  background: url("../images/ui/frame-mid.webp") top center / 100% auto repeat-y;
  padding: 0 calc(var(--fw) * 0.1);
  margin-top: -1px;        /* hide the seam under the header */
}

.frame-bottom {
  display: block;
  width: 100%;
  height: auto;
  margin-top: calc(var(--fw) * -0.112);   /* buttons sit over the ornaments */
  pointer-events: none;
}

/* Bronze-edged dark box around the inputs */
.fields {
  border: calc(var(--fw) * 0.031) solid transparent;
  border-image: url("../images/ui/fields-box.webp") 31 fill / calc(var(--fw) * 0.031) stretch;
  padding: calc(var(--fw) * 0.035) calc(var(--fw) * 0.05) calc(var(--fw) * 0.025);
  display: flex;
  flex-direction: column;
  gap: calc(var(--fw) * 0.025);
}

.form-heading {
  margin: 0;
  font-family: var(--title-font);
  font-size: calc(var(--fw) * 0.04);
  color: #c9925a;
  text-align: center;
}

label {
  display: block;
  margin-bottom: 4px;
  font-family: var(--btn-font);
  font-size: max(16px, calc(var(--fw) * 0.042));
  color: #cdbfb3;
}

input {
  width: 100%;
  padding: calc(var(--fw) * 0.02) 12px;
  background: #1d1c1e;
  border: 2px solid #7a4d30;
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.7);
}

input::placeholder { color: #6d6a70; }

input:focus-visible {
  outline: none;
  border-color: #d08a4c;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.7), 0 0 8px rgba(212,140,76,0.6);
}

.message {
  min-height: 1.3em;
  font-size: 15px;
  line-height: 1.3;
  text-align: center;
  color: #cdbfb3;
}

.message.error { color: #ff8a7a; }
.message.success { color: #8fd49f; }

/* Registration's "I agree to the ToS/Privacy" checkbox -- .fields'
   `input { width: 100% }` rule is for text inputs, so the checkbox
   itself is opted back out below. */
.tos-row { margin: 2px 0; }
.tos-row label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 0;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: #cdbfb3;
  cursor: pointer;
}
.tos-row input[type="checkbox"] {
  width: auto;
  flex: 0 0 auto;
  margin-top: 2px;
  box-shadow: none;
  accent-color: #d08a4c;
  cursor: pointer;
}
.tos-row a { color: #d4a24c; }
.tos-row a:hover { color: #e8b968; }

/* Big stone button — art has no text, label is real text */
.btn-main {
  display: block;
  width: 100%;
  aspect-ratio: 795 / 182;
  margin-top: calc(var(--fw) * 0.034);
  padding: 0;
  border: none;
  background: url("../images/ui/btn-stone.webp") center / 100% 100% no-repeat;
  font-family: var(--btn-font);
  font-weight: 700;
  font-size: calc(var(--fw) * 0.064);
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #d9c8bf;
  text-shadow: 0 0 1px #2a1510, 0 2px 0 #2a1510, 1px 0 0 #2a1510, -1px 0 0 #2a1510, 0 3px 6px rgba(0,0,0,0.6);
  cursor: pointer;
  transition: filter 0.15s;
}

.btn-main:hover { filter: brightness(1.15); }
.btn-main:focus-visible { outline: none; filter: brightness(1.2) drop-shadow(0 0 6px #d08a4c); }
.btn-main:disabled { filter: grayscale(0.4) brightness(0.8); cursor: default; }

.btn-row {
  position: relative;
  z-index: 2;              /* above the frame's bottom ornaments */
  display: flex;
  justify-content: center;
  gap: 4%;
  margin-top: calc(var(--fw) * 0.022);
}

/* Torn-parchment buttons */
.btn-small {
  width: 41.2%;
  aspect-ratio: 329 / 104;
  padding: 0 4px;
  border: none;
  background: url("../images/ui/btn-parchment.webp") center / 100% 100% no-repeat;
  font-family: var(--btn-font);
  font-size: calc(var(--fw) * 0.042);
  white-space: nowrap;
  color: var(--ink);
  cursor: pointer;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.5));
  transition: filter 0.15s;
}

.btn-small:hover { filter: drop-shadow(0 3px 4px rgba(0,0,0,0.5)) brightness(1.08); }
.btn-small:focus-visible { outline: 2px solid #d08a4c; outline-offset: 2px; }

[hidden] { display: none !important; }

/* ===== Side columns ===== */
.side {
  width: calc(var(--fw) * 0.66);
  flex: none;
  margin-top: calc(var(--fw) * 0.42);   /* line up with the frame, not the plaque */
}

/* Parchment scroll (pure CSS until real scroll art exists):
   aged paper with fibre texture, darkened edges, and a wooden
   rod with brass end caps at the top and bottom (::before/::after). */
.parchment {
  --rod-h: 22px;
  position: relative;
  margin-top: calc(var(--fw) * 0.42 + var(--rod-h) / 2);
  padding: 34px 26px 34px;
  color: var(--ink);
  background:
    /* fibre texture */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .38 0 0 0 0 .24 0 0 0 0 .1 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    /* age stains */
    radial-gradient(ellipse 40% 30% at 85% 78%, rgba(140,90,40,0.18), transparent 70%),
    radial-gradient(ellipse 35% 25% at 12% 35%, rgba(140,90,40,0.12), transparent 70%),
    /* light falling on the middle */
    radial-gradient(ellipse at 50% 45%, rgba(255,248,225,0.35), transparent 65%),
    linear-gradient(180deg, #d9bf8a, var(--parchment) 18%, var(--parchment) 82%, #cfb07a);
  box-shadow:
    /* paper curling into the rods */
    inset 0 16px 14px -12px rgba(70,40,12,0.55),
    inset 0 -16px 14px -12px rgba(70,40,12,0.55),
    /* burnt, darker side edges */
    inset 18px 0 22px -14px rgba(90,55,20,0.6),
    inset -18px 0 22px -14px rgba(90,55,20,0.6),
    0 12px 24px rgba(0,0,0,0.65);
  transform: rotate(-0.6deg);
}

/* The two rods. Brass caps poke out past the paper on both sides. */
.parchment::before,
.parchment::after {
  content: "";
  position: absolute;
  left: -16px;
  right: -16px;
  height: var(--rod-h);
  background:
    radial-gradient(circle at 50% 38%, #f3d27a 0 2px, #c9953b 4px, #7a5019 9px, #3d270c 11px, transparent 11.5px) left center / var(--rod-h) var(--rod-h) no-repeat,
    radial-gradient(circle at 50% 38%, #f3d27a 0 2px, #c9953b 4px, #7a5019 9px, #3d270c 11px, transparent 11.5px) right center / var(--rod-h) var(--rod-h) no-repeat,
    linear-gradient(180deg, #3a1f0e 0%, #8a5630 22%, #c08a55 38%, #7c4a26 60%, #4a2912 85%, #2a160a 100%) center / calc(100% - var(--rod-h) + 4px) 78% no-repeat;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,0.6));
  pointer-events: none;
}
.parchment::before { top: calc(var(--rod-h) / -2); }
.parchment::after  { bottom: calc(var(--rod-h) / -2); }

.parchment h2 {
  margin: 0 0 12px;
  text-align: center;
  font-family: var(--title-font);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4a2814;
  text-shadow: 0 1px 0 rgba(255,244,215,0.6);
}

/* Ink flourish under every scroll title: line — ◆ — line */
.parchment h2::after {
  content: "\25C6";
  font-family: "Segoe UI Symbol", Arial, sans-serif;
  display: block;
  margin: 6px auto 0;
  width: 75%;
  font-size: 12px;
  line-height: 12px;
  letter-spacing: 0;
  color: #7a4522;
  text-shadow: none;
  background:
    linear-gradient(90deg, transparent, rgba(110,62,28,0.75) 25%, rgba(110,62,28,0.75) 42%, transparent 44%, transparent 56%, rgba(110,62,28,0.75) 58%, rgba(110,62,28,0.75) 75%, transparent) center / 100% 1px no-repeat;
}

.news article { margin-bottom: 14px; font-size: 15px; line-height: 1.35; }
.news article:last-child { margin-bottom: 0; }
.news time { font-weight: 700; }
.news h3 { display: inline; font-size: 15px; font-weight: 700; margin: 0; }
.news p { margin: 2px 0 0; }

/* Screenshot gallery in the same frame style (9-slice) */
.gallery {
  border: solid transparent;
  border-width: calc(var(--fw) * 0.16) calc(var(--fw) * 0.11);
  border-image: url("../images/ui/panel.webp") 160 110 fill / calc(var(--fw) * 0.16) calc(var(--fw) * 0.11) stretch;
  filter: drop-shadow(0 12px 18px rgba(0,0,0,0.6));
}

.gallery-grid {
  margin: calc(var(--fw) * -0.11) calc(var(--fw) * -0.06);   /* use the frame's inner space */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.shot {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 480 / 350;
  border: 2px solid #8a5634;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px #2a1812, 0 2px 6px rgba(0,0,0,0.6);
  background: #1d1c1e;
}

.shot.wide { grid-column: span 2; aspect-ratio: 2 / 1; }

/* ===== Narrow screens: stack everything ===== */
@media (max-width: 1000px) {
  :root { --fw: min(460px, calc((100vw - 32px) / 1.2828)); }
  .layout { flex-direction: column; align-items: center; gap: 28px; }
  .frame-col { margin: 0 auto; order: -1; }
  .side { margin-top: 0; width: min(100%, calc(var(--fw) * 1.1)); }
  .parchment { transform: none; }
}

@media (max-width: 520px) {
  /* Let the plaque's outer ends run off-screen so the frame gets more room. */
  :root { --fw: calc(100vw - 40px); }
  .btn-row { gap: 3%; }
  .btn-small { width: 48.5%; font-size: 15px; }
}

/* ===== Selectable list inside the frame (characters, game modes) ===== */
.pick-list {
  display: flex;
  flex-direction: column;
  gap: calc(var(--fw) * 0.018);
  max-height: calc(var(--fw) * 0.95);   /* ~5 rows, then it scrolls */
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: #7a4d30 transparent;
}

.pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: calc(var(--fw) * 0.022) calc(var(--fw) * 0.03);
  background: linear-gradient(180deg, #26221f, #1b1917);
  border: 2px solid #5a3a24;
  border-radius: 5px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 -2px 6px rgba(0,0,0,0.5);
  color: var(--text-primary);
  font-family: var(--btn-font);
  font-size: max(16px, calc(var(--fw) * 0.042));
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pick:hover { border-color: #9a643c; }
.pick:focus-visible { outline: none; border-color: #d08a4c; }

.pick.selected {
  border-color: #d08a4c;
  box-shadow: inset 0 0 12px rgba(208,138,76,0.25), 0 0 8px rgba(208,138,76,0.45);
}

.pick:disabled { opacity: 0.45; cursor: default; }
.pick:disabled:hover { border-color: #5a3a24; }

.pick .pick-name { font-weight: 700; font-size: 1.1em; }
.pick .pick-sub { color: #a8998c; font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pick .pick-name { flex: none; }
.pick .pick-sub.active { color: #d8a45c; }

.pick.new {
  justify-content: center;
  border-style: dashed;
  color: #a8998c;
  background: rgba(20,18,16,0.6);
}
.pick.new:hover { color: var(--text-primary); }

/* Headings inside the dark box */
.box-title {
  margin: 0;
  font-family: var(--btn-font);
  font-size: max(16px, calc(var(--fw) * 0.042));
  color: #cdbfb3;
}

/* Details sheet (selected character / game mode) */
.parchment.details h2 { margin-bottom: 6px; }
.details .details-sub {
  margin: 0 0 16px;
  text-align: center;
  font-style: italic;
  color: #6b4526;
}
/* Ledger rows: label left, value right, faint inked rule between */
.details dl { margin: 0; display: grid; grid-template-columns: auto 1fr; font-size: 16px; }
.details dt,
.details dd {
  padding: 6px 0;
  border-bottom: 1px dashed rgba(100,60,25,0.35);
}
.details dt:last-of-type,
.details dd:last-of-type { border-bottom: none; }
.details dt {
  font-family: var(--title-font);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b4526;
  align-self: center;
}
.details dd { margin: 0; text-align: right; font-weight: 500; }
.details p { font-size: 16px; line-height: 1.4; margin: 0 0 10px; }

/* Keeps the frame centred when a page has a side panel on one side only */
.side.spacer { visibility: hidden; }

@media (max-width: 1000px) {
  .side.spacer { display: none; }
}
