/* ============================================================
   reglement.css — FFTA / FFTL rulebook reader + question assistant (public page).
   Same look as the public competition map; the left menu is public-menu.js.
   ============================================================ */
/* Tokens (palette, fonts, --brand) come from /_static/public-shell.css, the single definition for the public pages. */

* { box-sizing: border-box; margin: 0; padding: 0 }
html, body { height: 100% }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45 }
button { font: inherit; color: inherit; cursor: pointer }
[hidden] { display: none !important }
.muted { color: var(--muted) }
.link { background: none; border: 0; color: var(--focus); padding: 4px 2px; font-size: 13px; text-decoration: underline }

.wrap { height: 100vh; height: 100svh; min-height: 520px; display: flex; flex-direction: column; gap: 12px;
  padding: 16px clamp(16px, 2vw, 32px) 0 }

/* ---- Header (as the competition map) ----------------------------- */
header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; flex: none }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font: 800 19px "Syne", var(--display);
  white-space: nowrap; padding-right: 18px; border-right: 1px solid var(--line) }
.brand .brand-mark { width: 30px; height: 30px; color: var(--brand) }
.brand b { color: var(--brand); font-weight: 800 }
.signin { margin-left: auto; font: 600 15px var(--body); text-decoration: none; color: var(--bg); background: var(--brand);
  border-radius: 6px; padding: 8px 16px; white-space: nowrap }
.signin:hover { opacity: .88 }
h1 { font-family: var(--display); font-weight: 700; font-size: 34px; line-height: 1.05; letter-spacing: .01em; text-wrap: balance }
.sub { color: var(--muted) }
.sub a { color: var(--focus) }

.seg { display: inline-flex; align-self: flex-start; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); flex: none }
.seg button { font: 600 15px var(--display); letter-spacing: .03em; color: var(--muted); background: none; border: 0;
  border-right: 1px solid var(--line); padding: 7px 16px }
.seg button:last-child { border-right: 0 }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--bg) }

.rs-main { flex: 1; min-height: 0; position: relative; border-top: 1px solid var(--line) }
.rs-view { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0 }

/* ---- Assistant ------------------------------------------------------ */
.ask-scroll { flex: 1; overflow-y: auto; padding: 20px 0 8px; -webkit-overflow-scrolling: touch }
.ask-intro, .thread { max-width: 780px; margin: 0 auto }
.ask-intro h2 { font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.1; margin-bottom: 8px; text-wrap: balance }
.ask-intro p { color: var(--muted); font-size: 15px; margin-bottom: 14px }
.chips { display: flex; flex-wrap: wrap; gap: 8px }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; font: 500 14px var(--body); color: var(--ink); text-align: left }
.chip:hover { border-color: var(--brand) }
.thread { display: flex; flex-direction: column; gap: 18px; padding-bottom: 12px }
.msg-q { align-self: flex-end; max-width: 88%; background: color-mix(in srgb, var(--brand) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line)); border-radius: 12px 12px 4px 12px; padding: 9px 13px; white-space: pre-wrap }
.msg-a { background: var(--surface); border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; padding: 14px 16px }
.msg-a.err { border-color: var(--bad) }
.msg-a .src { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; align-items: center }
.msg-a .src b { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin-right: 4px }
.cite { display: inline-block; background: color-mix(in srgb, var(--brand) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--line));
  color: var(--ink); border-radius: 6px; padding: 0 6px; font-size: 12.5px; line-height: 1.6; margin: 0 1px; text-decoration: none; font-variant-numeric: tabular-nums }
.cite:hover { background: color-mix(in srgb, var(--brand) 26%, var(--surface)) }
.typing { color: var(--muted); display: flex; gap: 8px; align-items: center }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: bl 1s infinite ease-in-out }
.typing i:nth-child(2) { animation-delay: .15s } .typing i:nth-child(3) { animation-delay: .3s }
@keyframes bl { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }

.ask-bar { flex: none; padding: 8px 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg) }
.ask-opts, .ask-row { max-width: 780px; margin: 0 auto }
.ask-opts { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 10px }
.sel { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px }
.sel select { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: 400 14px var(--body); text-transform: none; letter-spacing: 0 }
.ask-row { display: flex; gap: 8px; align-items: flex-end }
.ask-row textarea { flex: 1; resize: none; max-height: 140px; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font: 400 15px var(--body); line-height: 1.4 }
.ask-row textarea:focus, .toc-search input:focus { outline: 2px solid var(--focus); outline-offset: -1px }
.btn-send { background: var(--brand); border: 0; color: var(--bg); border-radius: 8px; width: 44px; height: 44px; display: grid; place-items: center; flex: none }
.btn-send:disabled { opacity: .45; cursor: default }
.disclaimer { max-width: 780px; margin: 6px auto 0; font-size: 12.5px; color: var(--muted) }

/* ---- Prose (answers, extracts) ------------------------------------- */
.prose p { margin: 0 0 10px }
.prose p:last-child { margin-bottom: 0 }
.prose ul { margin: 0 0 10px; padding-left: 20px }
.prose li { margin: 3px 0 }
.prose h4 { font-size: 15px; margin: 12px 0 6px }
.prose strong { font-weight: 600 }
.prose .art { display: inline-block; margin: 14px 0 4px; padding: 1px 8px; border-radius: 6px; background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--line)); color: var(--ink); font: 600 13px var(--body); font-variant-numeric: tabular-nums }
.prose .art:first-child { margin-top: 0 }
.prose table { border-collapse: collapse; margin: 6px 0 12px; font-size: 14px; display: block; overflow-x: auto; max-width: 100% }
.prose th, .prose td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top }
.prose th { background: var(--bg) }
.fig { margin: 10px 0 14px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface) }
.fig img { display: block; max-width: 100%; height: auto; margin: 0 auto }
.fig-note { border-top: 1px solid var(--line) }
.fig-note summary { padding: 8px 12px; font-size: 13px; color: var(--muted); cursor: pointer }
.fig-note .prose { padding: 4px 12px 10px }

/* ---- Reader ------------------------------------------------------------ */
#view-read { flex-direction: row }
.toc { width: 320px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0 }
.toc-search { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line) }
.toc-search input { width: 100%; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; font: 400 15px var(--body) }
#toc-tree { flex: 1; overflow-y: auto; padding: 8px 8px 24px 0 }
.tn { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: 6px 8px; color: var(--muted); font: 400 14.5px var(--body); line-height: 1.35 }
.tn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink) }
.tn.on { background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--ink) }
.tn.l0 { color: var(--ink); font: 600 16px var(--display); letter-spacing: .02em; margin-top: 8px }
.tn.l1 { padding-left: 18px }
.tn.l2 { padding-left: 30px }
.tn .pg { float: right; color: var(--muted); font-size: 12.5px; margin-left: 8px; font-variant-numeric: tabular-nums }
.reader { flex: 1; overflow-y: auto; padding: 20px 0 60px 24px; min-width: 0; -webkit-overflow-scrolling: touch }
#reader-body { max-width: 820px; margin: 0 auto }
.toc-toggle { display: none }
.rd-h { font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.1; margin: 4px 0 4px; text-wrap: balance }
.rd-sub { color: var(--muted); font-size: 14px; margin-bottom: 14px }
.rd-chunk { padding: 14px 0; border-top: 1px solid var(--line) }
.rd-chunk.flash { animation: fl 1.8s ease-out }
@keyframes fl { 0% { background: color-mix(in srgb, var(--brand) 22%, transparent) } 100% { background: transparent } }
.rd-meta { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 10px; flex-wrap: wrap }
.rd-meta a { color: var(--focus) }
.res { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px }
.res:hover { border-color: var(--brand) }
.res .t { font-size: 13px; color: var(--muted); margin-bottom: 3px }
.res .s { font-size: 14.5px }
.res mark { background: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--ink); border-radius: 3px; padding: 0 1px }
.more { margin: 14px 0 0 }

/* ---- Drawer ------------------------------------------------------------ */
.drawer-bk { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40 }
.drawer { position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--bg); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(0, 0, 0, .25) }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line) }
.drawer-crumb { font-size: 14px; color: var(--muted); line-height: 1.4 }
.drawer-links { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap }
.drawer-links a, .drawer-links button { color: var(--focus); font-size: 14px; background: none; border: 0; padding: 0; text-decoration: underline }
.icon-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px; color: var(--muted) }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px }

/* ---- Small screens ----------------------------------------------------- */
@media (max-width: 820px) {
  h1 { font-size: 28px }
  .brand { border-right: 0; padding-right: 0 }
  header h1 { order: 3; flex-basis: 100% }
  header .sub { order: 4 }
  .seg { width: 100% }
  .seg button { flex: 1 }
  .toc { position: absolute; z-index: 5; inset: 0; width: 100%; border: 0; background: var(--bg) }
  #view-read:not(.toc-open) .toc { display: none }
  .toc-toggle { display: block; position: sticky; top: -14px; z-index: 3; width: calc(100% + 28px); margin: -14px -14px 8px; padding: 10px 14px;
    background: var(--bg); border-bottom: 1px solid var(--line); text-align: left }
  .toc-search { padding-right: 0 }
  .reader { padding: 14px 0 60px }
  .msg-q { max-width: 94% }
  .drawer { width: 100% }
}
