/* Good Luck Alliance — one stylesheet for the whole public site and admin.
 *
 * Layout is a single centred column. The only two-column layout is the tips
 * page, where the contents list sticks beside the text on wide screens and
 * folds into a <details> block on narrow ones.
 */

:root {
  --bg: #fbf9f5;
  --surface: #ffffff;
  --ink: #1f1b16;
  --ink-soft: #5c554b;
  --line: #e2dcd1;
  --accent: #a8761f;
  --accent-ink: #ffffff;
  --notice-bg: #fdf5e3;
  --notice-line: #e6c88a;
  --danger: #a12a2a;
  --radius: 10px;
  --wrap: 62rem;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17150f;
    --surface: #201d17;
    --ink: #f2ede3;
    --ink-soft: #b3aa9a;
    --line: #3a352c;
    --accent: #dfae52;
    --accent-ink: #1a1710;
    --notice-bg: #2a2314;
    --notice-line: #5b4a24;
    --danger: #e08484;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; z-index: 20;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ---------------------------------------------------------------- header */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding-top: .85rem;
  padding-bottom: .85rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -.01em;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2.1rem; height: 2.1rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: .85rem;
  letter-spacing: .02em;
}

.brand-name { font-size: 1.05rem; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: .95rem;
}
.site-nav a:hover { color: var(--ink); text-decoration: underline; }
.site-nav .nav-quiet { color: var(--ink-soft); }

.inline-form { display: inline; margin: 0; }

.discord-button {
  display: inline-block;
  background: #5865f2;
  color: #fff;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  padding: .5rem .9rem;
  border-radius: var(--radius);
}
.discord-button:hover { background: #4752c4; }

/* ------------------------------------------------------------------ main */

main { padding: 2.5rem 1.25rem 4rem; min-height: 60vh; }

.page-head { margin-bottom: 2rem; }
.page-head h1 { margin: 0 0 .4rem; font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.4rem); line-height: 1.15; letter-spacing: -.02em; }
.lede { color: var(--ink-soft); margin: 0; max-width: 46rem; }
.meta { color: var(--ink-soft); font-size: .87rem; margin: .25rem 0 .6rem; }
.section-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-soft);
  margin: 2.5rem 0 1rem;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  padding: .55rem 1rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { filter: brightness(1.06); }
.button-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.button-danger { background: var(--danger); color: #fff; }

.link-button {
  background: none; border: 0; padding: 0; margin: 0;
  color: var(--accent); font: inherit; font-size: .9rem; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

/* --------------------------------------------------------------- notices */

.notice-block {
  background: var(--notice-bg);
  border: 1px solid var(--notice-line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1rem;
}
.notice-block .section-label { margin-top: 0; color: var(--ink-soft); }
.notice + .notice { border-top: 1px solid var(--notice-line); padding-top: .9rem; margin-top: .9rem; }
.notice h3 { margin: 0 0 .15rem; font-size: 1.15rem; }
.notice p { margin: .2rem 0 0; }

/* ------------------------------------------------------------- tips link */

.tips-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  margin: 2rem 0 0;
}
.tips-callout h2 { margin: 0 0 .15rem; font-size: 1.05rem; }
.tips-callout p { margin: 0; color: var(--ink-soft); font-size: .93rem; }

/* ----------------------------------------------------------------- posts */

.post-list { list-style: none; margin: 0; padding: 0; }
.post-card {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}
.post-card:first-child { padding-top: 0; }
.post-card h2, .post-card h3 { margin: 0 0 .1rem; font-size: 1.2rem; }
.post-card h2 a, .post-card h3 a { color: var(--ink); text-decoration: none; }
.post-card h2 a:hover, .post-card h3 a:hover { text-decoration: underline; }
.post-card p { margin: 0; color: var(--ink-soft); }

.empty-state {
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.pill {
  display: inline-block;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  background: var(--notice-bg);
  border: 1px solid var(--notice-line);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: .15rem .6rem;
  margin: 0 0 .6rem;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
}
.pager-status { color: var(--ink-soft); font-size: .9rem; }

.back-link { margin-top: 2.5rem; }

/* ----------------------------------------------------------------- prose */

.prose { max-width: 44rem; }
.prose h2 { margin: 2.2rem 0 .6rem; font-size: 1.45rem; scroll-margin-top: 5rem; }
.prose h3 { margin: 1.8rem 0 .5rem; font-size: 1.2rem; scroll-margin-top: 5rem; }
.prose h4 { margin: 1.5rem 0 .4rem; font-size: 1.02rem; scroll-margin-top: 5rem; }
.prose p { margin: 0 0 1rem; }
.prose ul, .prose ol { margin: 0 0 1rem; padding-left: 1.4rem; }
.prose li { margin: .25rem 0; }
.prose blockquote {
  margin: 0 0 1rem;
  padding: .3rem 0 .3rem 1rem;
  border-left: 3px solid var(--line);
  color: var(--ink-soft);
}
.prose pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: .88rem;
}
.prose code { font-family: var(--mono); font-size: .9em; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.prose a { overflow-wrap: anywhere; }

/* ------------------------------------------------------------ tips layout */

.tips-layout {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: 5.5rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  border-left: 2px solid var(--line);
  padding-left: 1rem;
  font-size: .92rem;
}
.toc summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-soft);
  margin-bottom: .5rem;
  list-style: none;
}
.toc summary::-webkit-details-marker { display: none; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul ul { padding-left: .9rem; }
.toc li { margin: .2rem 0; }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 900px) {
  .tips-layout { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .toc {
    position: static;
    max-height: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .9rem 1.1rem;
    background: var(--surface);
  }
  .toc summary { margin-bottom: .6rem; }
}

/* ------------------------------------------------------------------ forms */

.narrow { max-width: 26rem; }

.stack { display: flex; flex-direction: column; gap: .55rem; }
.stack label { font-weight: 600; font-size: .92rem; margin-top: .8rem; }
.stack input[type="text"], .stack input[type="password"], .stack textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  width: 100%;
}
.stack input:focus, .stack textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.stack textarea { resize: vertical; }
.stack .button { margin-top: 1rem; align-self: flex-start; }

.hint { color: var(--ink-soft); font-size: .85rem; font-weight: 400; }

.form-error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: .7rem .9rem;
}
.form-error:has(+ .stack) { margin-bottom: .5rem; }

.flash {
  background: var(--notice-bg);
  border: 1px solid var(--notice-line);
  border-radius: var(--radius);
  padding: .7rem .9rem;
  margin-bottom: 1.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------- admin area */

.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.table-scroll { overflow-x: auto; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .93rem;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: .6rem .5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.admin-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.row-actions { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; }
.row-actions form { margin: 0; }

.status {
  display: inline-block;
  font-size: .78rem;
  padding: .1rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.status-published { background: var(--notice-bg); border-color: var(--notice-line); }
.status-draft { color: var(--ink-soft); }

.editor-form { max-width: 52rem; }
.editor { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.editor .ql-toolbar { border: 0; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.editor .ql-container { border: 0; font-family: var(--font); font-size: 1rem; }
.editor .ql-editor { min-height: 22rem; }
.editor .ql-editor img { max-width: 100%; }

.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: 1.2rem; }

.danger-zone {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  display: flex;
  gap: .8rem;
  align-items: center;
  flex-wrap: wrap;
}

.upload-form { max-width: 32rem; margin-bottom: 2.5rem; }

.media-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 1rem;
}
.media-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem;
}
.media-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}
.media-card p { margin: .3rem 0; font-size: .82rem; }
.copy-field {
  width: 100%;
  font-family: var(--mono);
  font-size: .72rem;
  padding: .3rem .4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink-soft);
  margin: .3rem 0;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: .88rem;
  padding: 1.5rem 0;
}
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-inner p { margin: 0; }

/* ------------------------------------------------------------- mobile nav */

@media (max-width: 640px) {
  body { font-size: 16px; }

  /* A sticky header must not eat the screen. Flex-wrap gives three rows on a
     phone (brand, button, navigation), so the header becomes a two-row grid:
     brand and Discord button, then the navigation across the full width. This is
     deterministic; flex-wrap depended on text width. */
  .header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: .6rem;
    row-gap: .45rem;
    padding-top: .7rem;
    padding-bottom: .6rem;
  }
  .brand { grid-column: 1; grid-row: 1; min-width: 0; }
  .brand-name { font-size: 1rem; }
  .discord-button {
    grid-column: 2; grid-row: 1;
    padding: .4rem .7rem;
    font-size: .82rem;
    white-space: nowrap;
  }
  .site-nav { grid-column: 1 / -1; grid-row: 2; margin-left: 0; gap: .95rem; font-size: .9rem; }

  main { padding-top: 1.5rem; }
  .admin-head { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}