/* Gloria Victis Builds — medieval theme.
   Inspired by the in-game character / build UI: dark slate ground, aged
   parchment panels with gold trim, heraldic red accents. Serifs for display
   (Cinzel) and body copy (EB Garamond); falls back to system stacks. */

:root {
  --bg-0:        #0e0a06;
  --bg-1:        #1a1410;
  --panel:       #221a13;
  --panel-edge:  #3a2a1c;
  --parchment:   #ebdfc1;
  --gold:        #c9a35b;
  --gold-deep:   #8a6a2e;
  --gold-soft:   #d8b97a;
  --red:         #8a1c1c;
  --red-soft:    #b03030;
  --green:       #4f7a3a;
  --green-soft:  #7aa05a;
  --text:        #e8dcc4;
  --muted:       #9a8e76;
  --dim:         #6f6553;
  --line:        #3a2a1c;
  --line-soft:   #2a2018;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
  background:
    radial-gradient(1200px 700px at 50% -10%, #221a14 0%, var(--bg-0) 60%),
    var(--bg-0);
  color: var(--text);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--gold-soft); text-decoration: none; }
a:hover { color: var(--gold); text-decoration: underline; text-decoration-color: var(--gold-deep); }

h1, h2, h3 { font-family: 'Cinzel', Georgia, serif; font-weight: 600; letter-spacing: 0.02em; color: var(--gold-soft); margin: 0 0 12px; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
.display { font-size: 44px; line-height: 1.1; margin-bottom: 14px; }

/* ---- topbar ----------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: linear-gradient(180deg, #1a130d 0%, #0e0a06 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 #2a1f15 inset, 0 2px 0 #000;
}
.brand a { color: var(--parchment); font-family: 'Cinzel', serif; font-size: 22px; font-weight: 700; letter-spacing: 0.08em; text-decoration: none; }
.brand-mark { color: var(--gold); margin-right: 4px; font-size: 22px; }
.brand-sub  { color: var(--gold-soft); font-weight: 500; margin-left: 4px; }

.nav { display: flex; gap: 6px; align-items: center; }
.nav a, .nav .link {
  padding: 8px 14px; border-radius: 3px; font-family: 'Cinzel', serif; font-size: 14px;
  letter-spacing: 0.06em; color: var(--text); text-transform: uppercase;
}
.nav a:hover, .nav .link:hover { background: rgba(201,163,91,0.08); color: var(--gold-soft); text-decoration: none; }
.nav a.active { color: var(--gold); border-bottom: 1px solid var(--gold-deep); border-radius: 0; }
.nav .cta { background: var(--gold-deep); color: #1a130d; border: 1px solid var(--gold); }
.nav .cta:hover { background: var(--gold); color: #1a130d; }
.nav .admin { color: var(--red-soft); }
.nav .link { background: none; border: 0; cursor: pointer; }
.inline { display: inline; }

/* ---- page shell ------------------------------------------------------- */
.page { flex: 1; max-width: 1240px; margin: 0 auto; padding: 28px 28px 64px; width: 100%; }

.panel {
  background: linear-gradient(180deg, var(--panel) 0%, #1c1610 100%);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 22px 24px;
  margin: 0 0 22px;
  position: relative;
  box-shadow: 0 1px 0 #3a2a1c inset, 0 2px 4px rgba(0,0,0,0.4);
}
.panel::before, .panel::after {
  content: ''; position: absolute; top: 6px; width: 18px; height: 18px;
  border: 1px solid var(--gold-deep); opacity: 0.6; pointer-events: none;
}
.panel::before { left: 6px;  border-right: 0; border-bottom: 0; }
.panel::after  { right: 6px; border-left:  0; border-bottom: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.panel-head h1, .panel-head h2 { margin: 0; }
.panel-head .more { font-size: 13px; }

/* ---- hero ------------------------------------------------------------- */
.hero {
  position: relative;
  background:
    linear-gradient(135deg, rgba(20,14,8,0.6) 0%, rgba(20,14,8,0.95) 70%),
    radial-gradient(800px 400px at 20% 30%, #3a2a1c 0%, transparent 70%);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 64px 56px;
  margin-bottom: 28px;
  overflow: hidden;
}
.hero-inner { position: relative; z-index: 2; max-width: 700px; }
.hero h1 { color: var(--parchment); }
.hero .lead { font-size: 19px; color: var(--text); max-width: 60ch; }
.hero-cta { margin-top: 22px; display: flex; gap: 12px; }
.hero-banner {
  position: absolute; right: -40px; top: 50%; transform: translateY(-50%);
  width: 320px; height: 320px;
  background: radial-gradient(circle at center, rgba(201,163,91,0.18), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* ---- buttons ---------------------------------------------------------- */
.btn { display: inline-block; padding: 10px 18px; border-radius: 3px; font-family: 'Cinzel', serif; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: background 0.15s, color 0.15s; }
.btn-gold { background: var(--gold-deep); color: #1a130d; border-color: var(--gold); }
.btn-gold:hover { background: var(--gold); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--gold-soft); border-color: var(--line); }
.btn-ghost:hover { background: rgba(201,163,91,0.08); border-color: var(--gold-deep); text-decoration: none; }
.btn-danger { background: var(--red); color: var(--parchment); border-color: var(--red-soft); }
.btn-danger:hover { background: var(--red-soft); text-decoration: none; }

/* ---- flash + errors --------------------------------------------------- */
.flash {
  max-width: 1240px; margin: 12px auto 0; padding: 10px 18px; border-radius: 3px;
  font-family: 'Cinzel', serif; font-size: 13px; letter-spacing: 0.06em;
}
.flash-notice { background: rgba(79,122,58,0.18); color: var(--green-soft); border: 1px solid var(--green); }
.flash-error  { background: rgba(138,28,28,0.18); color: #e8b8b8; border: 1px solid var(--red-soft); }
.error-banner { padding: 10px 14px; margin-bottom: 14px; background: rgba(138,28,28,0.15); border: 1px solid var(--red-soft); color: #f4d2d2; border-radius: 3px; }

/* ---- forms ------------------------------------------------------------ */
.auth-panel { max-width: 460px; margin: 40px auto; background: linear-gradient(180deg, var(--panel) 0%, #1c1610 100%); border: 1px solid var(--line); border-radius: 4px; padding: 32px 36px; }
.auth-panel h1 { text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-family: 'Cinzel', serif; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.auth-form .hint { font-family: 'EB Garamond', serif; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--dim); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  background: #110c08; color: var(--text);
  border: 1px solid var(--line); border-radius: 3px;
  padding: 9px 12px; font: inherit; font-family: 'EB Garamond', serif; font-size: 16px;
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--gold-deep); background: #160f08; }
.muted { color: var(--muted); }
.dim   { color: var(--dim); }

/* ---- build cards ------------------------------------------------------ */
.build-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.build-card { background: #1a130d; border: 1px solid var(--line); border-radius: 3px; transition: border-color 0.15s, transform 0.15s; }
.build-card a { display: block; padding: 16px 18px; color: var(--text); text-decoration: none; height: 100%; }
.build-card:hover { border-color: var(--gold-deep); transform: translateY(-1px); }
.build-card h3 { margin: 6px 0 4px; color: var(--parchment); font-family: 'Cinzel', serif; font-size: 18px; }
.card-tag { font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); }
.profile-meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 8px 0 0; }
.profile-meta dt { font-family: 'Cinzel', serif; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.profile-meta dd { margin: 0; color: var(--text); }
.profile-meta .gold { color: var(--gold); }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 4px; }
.card-meta-inline { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* ---- tag pills (display) + tag chip-checkboxes (form) ---------------- */
.tag-pill {
  display: inline-block; padding: 2px 8px;
  font-family: 'Cinzel', serif; font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--gold-soft);
  background: rgba(201,163,91,0.10);
  border: 1px solid var(--gold-deep); border-radius: 2px;
  line-height: 1.4;
}
.tag-checkboxes { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 2px; }
.tag-check { cursor: pointer; }
.tag-check input { position: absolute; opacity: 0; pointer-events: none; }
.tag-check span {
  display: inline-block; padding: 5px 11px;
  font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; text-transform: uppercase;
  background: #160f08; color: var(--muted);
  border: 1px solid var(--line); border-radius: 3px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.tag-check:hover span { border-color: var(--gold-deep); color: var(--gold-soft); }
.tag-check input:checked + span {
  background: linear-gradient(180deg, #3a2c14 0%, #2a1f0e 100%);
  border-color: var(--gold-deep); color: var(--gold);
}
.tag-check input:focus-visible + span { outline: 2px solid var(--gold-deep); outline-offset: 1px; }
.card-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---- features (landing) ---------------------------------------------- */
.three-up { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.feature { padding: 18px; background: #1a130d; border: 1px solid var(--line); border-radius: 3px; }
.feature-icon { font-size: 24px; color: var(--gold); margin-bottom: 6px; }
.feature h3 { margin-bottom: 4px; color: var(--parchment); }
.feature p { color: var(--muted); font-size: 15px; }

/* ---- filters --------------------------------------------------------- */
.filters { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.filters label { display: flex; flex-direction: column; gap: 4px; font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* ---- build form ------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-family: 'Cinzel', serif; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .checkbox { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }
@media (max-width: 820px) { .form-grid { grid-template-columns: 1fr; } }

/* ---- forge layout (calculator / show / form) ------------------------- */
.forge-layout { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 18px; align-items: start; }
.forge-left { display: flex; flex-direction: column; gap: 18px; }
.forge-left .panel, .forge-right .panel { margin-bottom: 0; }
@media (max-width: 880px) { .forge-layout { grid-template-columns: 1fr; } }

/* ---- attribute editor ------------------------------------------------ */
.attr-editor { display: flex; flex-direction: column; gap: 8px; }
.attr-row { display: grid; grid-template-columns: 1fr auto 70px auto; gap: 8px; align-items: center; padding: 8px 10px; background: #160f08; border: 1px solid var(--line-soft); border-radius: 3px; }
.attr-name { font-family: 'Cinzel', serif; font-size: 13px; letter-spacing: 0.06em; color: var(--gold-soft); }
.attr-row .step { background: #110c08; color: var(--gold-soft); border: 1px solid var(--line); width: 28px; height: 28px; border-radius: 3px; cursor: pointer; font-size: 16px; line-height: 1; }
.attr-row .step:hover { border-color: var(--gold-deep); color: var(--gold); }
.attr-val { padding: 6px 8px; text-align: center; font-size: 15px; }

/* ---- stat tables ----------------------------------------------------- */
.stat-table { width: 100%; border-collapse: collapse; }
.stat-table th, .stat-table td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; font-size: 15px; }
.stat-table th { color: var(--muted); font-family: 'Cinzel', serif; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }
.stat-table td { color: var(--text); text-align: right; }
.stat-table td.dim { color: var(--dim); }

/* ---- hex ability grid ------------------------------------------------ */
.tree-name { margin-top: 18px; color: var(--gold); font-family: 'Cinzel', serif; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.hex-grid { display: grid; grid-template-columns: repeat(7, 92px); grid-auto-rows: 80px; gap: 6px; padding: 12px 0; justify-content: center; }
.hex {
  width: 92px; height: 80px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 4px 6px;
  background: #160f08;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  border: 0;
  position: relative;
  font-size: 12px;
  color: var(--muted);
  cursor: default;
  user-select: none;
  transition: filter 0.12s;
}
.hex::before {
  content: ''; position: absolute; inset: 2px;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  background: #221a12;
  z-index: -1;
}
.hex.on { color: var(--gold-soft); background: linear-gradient(180deg, #3a2c14 0%, #2a1f0e 100%); box-shadow: 0 0 0 1px var(--gold-deep) inset; }
.hex-grid.editable .hex { cursor: pointer; }
.hex-grid.editable .hex:hover { filter: brightness(1.25); }
.hex-name { font-family: 'Cinzel', serif; font-size: 10px; letter-spacing: 0.05em; line-height: 1.1; }
.hex-rank { font-size: 11px; color: var(--gold); margin-top: 2px; }

/* ---- gear editor (legacy table-style display on /builds/:slug) -------- */
.gear-editor { display: grid; grid-template-columns: 1fr; gap: 6px; }
.gear-row { display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: center; }
.gear-slot { font-family: 'Cinzel', serif; font-size: 12px; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
.gear-val { padding: 6px 8px; font-size: 14px; }

/* ---- gear paper-doll (build form) ------------------------------------ */
/* Stylized humanoid silhouette in the centre with 8 slot boxes positioned
   around the body parts they represent. Click any box to focus its hidden
   input — eventually that'll open a game-item search picker. */
.gear-panel { padding-bottom: 28px; }
.gear-paperdoll {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 580px;
  margin: 6px auto 0;
}
.gear-figure-svg {
  position: absolute;
  top: 25px;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: auto;
  pointer-events: none;
  z-index: 0;
}
.gear-slot-box {
  position: absolute;
  width: 96px;
  height: 70px;
  z-index: 1;
  display: flex; flex-direction: column;
  justify-content: center; gap: 3px;
  padding: 7px 10px;
  background: linear-gradient(180deg, #1c1610 0%, #140e08 100%);
  border: 1px solid var(--gold-deep);
  border-radius: 3px;
  cursor: text;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  box-shadow: 0 1px 0 #2a1f15 inset;
}
.gear-slot-box:hover, .gear-slot-box:focus-within {
  border-color: var(--gold);
  background: linear-gradient(180deg, #2a1f0e 0%, #1a130d 100%);
  box-shadow: 0 0 8px rgba(201,163,91,0.25);
}
.gear-slot-name {
  font-family: 'Cinzel', serif; font-size: 10px;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--gold-soft);
  line-height: 1;
}
.gear-val {
  background: transparent; border: 0; padding: 0;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 13px; color: var(--text);
  width: 100%; min-width: 0;
}
.gear-val:focus { outline: none; }
.gear-val::placeholder { color: var(--dim); font-style: italic; }

/* Slot positions — each sits next to the corresponding body part. */
.gear-slot-head      { top: 15px;  left: 30px; }
.gear-slot-shoulders { top: 15px;  right: 30px; }
.gear-slot-gloves    { top: 115px; left: 8px; }
.gear-slot-chest     { top: 115px; right: 8px; }
.gear-slot-weapon    { top: 220px; left: 8px; }
.gear-slot-shield    { top: 220px; right: 8px; }
.gear-slot-pants     { top: 330px; left: 30px; }
.gear-slot-boots     { top: 470px; left: 30px; }

/* Mobile fallback: drop absolute layout, stack as a 2-column grid. */
@media (max-width: 560px) {
  .gear-paperdoll { height: auto; max-width: 100%; display: grid;
                    grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 0; }
  .gear-figure-svg { display: none; }
  .gear-slot-box { position: static; width: 100%; height: auto; }
}

/* ---- build head ------------------------------------------------------ */
.build-page { display: flex; flex-direction: column; gap: 16px; }
.build-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 24px; background: linear-gradient(180deg, var(--panel) 0%, #1c1610 100%); border: 1px solid var(--line); border-radius: 4px; }
.build-head h1 { margin: 4px 0; color: var(--parchment); }
.build-actions { display: flex; gap: 8px; }
.prose { white-space: pre-wrap; color: var(--text); }

/* ---- admin ----------------------------------------------------------- */
.stat-strip { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 140px; padding: 14px; background: #160f08; border: 1px solid var(--line); border-radius: 3px; text-align: center; }
.stat-num { font-family: 'Cinzel', serif; font-size: 28px; color: var(--gold); }
.stat-lbl { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-family: 'Cinzel', serif; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.admin-table th { font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.admin-table .row-actions { white-space: nowrap; }
.admin-table .link { background: none; border: 0; color: var(--gold-soft); cursor: pointer; padding: 0 8px; font: inherit; }
.admin-table .link.danger { color: var(--red-soft); }
.admin-table .link:hover { text-decoration: underline; }

/* ---- error page ------------------------------------------------------ */
.error-page { text-align: center; padding: 80px 0; }
.error-code { font-family: 'Cinzel', serif; font-size: 96px; color: var(--gold-deep); letter-spacing: 0.05em; }
.error-page h1 { color: var(--parchment); }
.error-page p { color: var(--muted); margin: 0 0 20px; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* ---- footer ---------------------------------------------------------- */
.footer { border-top: 1px solid var(--line); padding: 18px 28px; margin-top: 30px; background: #0a0704; }
.footer-inner { max-width: 1240px; margin: 0 auto; display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
