/*
Theme Name: Ashenfall
Description: Dark ember theme for the Ashenfall game site (Thai + English with Polylang).
Version: 1.0
Text Domain: ashenfall
*/

:root {
  --bg: #0e0b09;
  --bg2: #17120e;
  --panel: #1d1712;
  --line: #3a2c20;
  --text: #e9dfd0;
  --muted: #a8998a;
  --ember: #ff7a2f;
  --ember2: #e0552a;
  --gold: #d9a54a;
  --magic: #8c8cff;
  --rare: #ffef77;
  --unique: #e08a3c;
  --fire: #ff8a4a;
  --frost: #7ac8ff;
  --shadow: #b48cff;
  --holy: #ffe08a;
  --head: "Cinzel", "Noto Serif Thai", serif;
  --body: "Noto Sans Thai", system-ui, sans-serif;
  --w: 1080px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg) radial-gradient(ellipse at 50% -10%, #2a170c 0%, transparent 60%) no-repeat;
  color: var(--text);
  font: 16px/1.75 var(--body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--ember); text-decoration: none; }
a:hover { color: #ffae6e; text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--head); color: #f4e6cf; line-height: 1.3; margin: 1.6em 0 .6em; letter-spacing: .02em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); margin-top: 0; }
h2 { font-size: 1.6rem; border-bottom: 1px solid var(--line); padding-bottom: .35em; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
code { background: #2a2018; padding: .1em .35em; border-radius: 4px; font-size: .9em; }
kbd {
  display: inline-block; min-width: 1.8em; padding: .05em .45em; text-align: center;
  background: linear-gradient(#352a20, #241c15); border: 1px solid #5a4430; border-bottom-width: 3px;
  border-radius: 5px; font: 600 .85em/1.5 var(--body); color: #f4e6cf;
}
.wrap { max-width: var(--w); margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(14, 11, 9, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 20px; min-height: 64px; }
.brand { font: 700 1.35rem/1 var(--head); letter-spacing: .14em; color: #f4e6cf; white-space: nowrap; }
.brand span { color: var(--ember); }
.brand:hover { text-decoration: none; color: #fff; }
.nav { flex: 1; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.nav li { position: relative; }
.nav a { display: block; padding: 8px 12px; color: var(--text); border-radius: 6px; font-weight: 600; font-size: .95rem; }
.nav a:hover, .nav .current-menu-item > a, .nav .current-menu-ancestor > a, .nav .current-page-ancestor > a { background: #2a1d14; color: var(--ember); text-decoration: none; }
.nav .sub-menu { display: none; position: absolute; top: 100%; left: 0; min-width: 230px; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; box-shadow: 0 12px 30px #000a; }
.nav li:hover > .sub-menu, .nav li:focus-within > .sub-menu { display: flex; }
.nav .sub-menu a { font-weight: 500; }
.lang { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.lang a { display: block; padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: .8rem; font-weight: 700; }
.lang .current-lang a { color: var(--ember); border-color: var(--ember2); }
.btn {
  display: inline-block; padding: 10px 22px; border-radius: 8px; font-weight: 700; letter-spacing: .03em;
  background: linear-gradient(180deg, #ff8c3c, #d4481e); color: #1a0d05; box-shadow: 0 0 0 1px #ffb27a55 inset, 0 6px 24px #ff5a1f40;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; color: #000; filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--text); box-shadow: 0 0 0 1px var(--line) inset; }
.btn.ghost:hover { color: var(--ember); box-shadow: 0 0 0 1px var(--ember2) inset; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 6px 10px; font-size: 1.1rem; cursor: pointer; }

@media (max-width: 900px) {
  .nav-toggle { display: block; margin-left: auto; }
  .site-header .wrap { flex-wrap: wrap; }
  .nav { display: none; flex-basis: 100%; order: 5; padding-bottom: 12px; }
  .site-header.open .nav { display: block; }
  .nav ul { flex-direction: column; }
  .nav .sub-menu { display: flex; position: static; box-shadow: none; border: 0; padding: 0 0 0 14px; background: none; }
  .header-play { display: none; }
}

/* ---------- hero ---------- */
.hero {
  position: relative; min-height: 340px; display: flex; align-items: flex-end;
  background: #120d0a center/cover no-repeat; border-bottom: 1px solid var(--line);
}
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, #0e0b0920 0%, #0e0b09cc 70%, var(--bg) 100%); }
.hero .wrap { position: relative; z-index: 1; width: 100%; padding-top: 80px; padding-bottom: 28px; }
.hero .kicker { color: var(--gold); font: 700 .8rem/1 var(--head); letter-spacing: .25em; text-transform: uppercase; margin-bottom: 10px; }
.hero h1 { text-shadow: 0 2px 20px #000; margin: 0; }
.hero .lead { color: #d8c8b4; font-size: 1.1rem; max-width: 720px; margin-top: 10px; text-shadow: 0 1px 8px #000; }
.hero.big { min-height: min(78vh, 640px); }
.hero.big h1 { font-size: clamp(2.6rem, 8vw, 5rem); letter-spacing: .12em; }
.hero.big h1 span { color: var(--ember); }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.hero.plain { min-height: 0; background: none; }
.hero.plain::after { display: none; }
.hero.plain .wrap { padding-top: 48px; }

/* ---------- content ---------- */
main { padding: 32px 0 64px; }
.content > *:first-child { margin-top: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); }
.children { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 28px; padding: 0; list-style: none; }
.children a { display: block; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); font-size: .9rem; }
.children a:hover, .children .current a { border-color: var(--ember2); color: var(--ember); text-decoration: none; }
.post-meta { color: var(--muted); font-size: .9rem; margin-bottom: 20px; }

.af-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin: 1.2em 0 2em; }
.af-grid.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.af-card {
  display: flex; flex-direction: column; background: linear-gradient(180deg, var(--panel), #15100c);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: var(--text);
  transition: border-color .15s, transform .15s;
}
a.af-card:hover { border-color: var(--ember2); transform: translateY(-2px); text-decoration: none; color: var(--text); }
.af-card img { aspect-ratio: 16/9; object-fit: cover; width: 100%; border-bottom: 1px solid var(--line); }
.af-card .in { padding: 14px 16px 16px; flex: 1; }
.af-card h3 { margin: 0 0 4px; font-size: 1.1rem; }
.af-card .sub { color: var(--gold); font-size: .85rem; margin-bottom: 6px; }
.af-card p { color: var(--muted); font-size: .92rem; margin: 0; }
.af-card .accent { height: 4px; }
.af-card .af-mstat { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.af-card .af-mstat span { background: #1e1712; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: .82rem; color: var(--text); font-variant-numeric: tabular-nums; }
.af-card .af-mwhere { margin-top: 8px; font-size: .82rem; color: var(--muted); }

.af-split { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: start; margin: 1.5em 0; }
.af-split img { border-radius: 12px; border: 1px solid var(--line); }
@media (max-width: 760px) { .af-split { grid-template-columns: 1fr; } }

.af-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 1em 0 1.6em; }
.af-stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.af-stats b { display: block; font: 700 1.25rem/1.2 var(--head); color: #f4e6cf; }
.af-stats span { color: var(--muted); font-size: .8rem; }

.table-scroll { overflow-x: auto; margin: 1em 0 2em; border: 1px solid var(--line); border-radius: 10px; }
.af-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.af-table th, .af-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid #2c2219; vertical-align: top; }
.af-table th { background: #241b14; color: var(--gold); font-weight: 700; white-space: nowrap; }
.af-table tr:last-child td { border-bottom: 0; }
.af-table tr:hover td { background: #1b1510; }
.af-table td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }

.af-quote {
  margin: 1.2em 0; padding: 14px 18px; border-left: 3px solid var(--ember2); background: #1b130e;
  border-radius: 0 10px 10px 0; font-style: italic; color: #e6d3bb;
}
.af-quote cite { display: block; margin-top: 6px; font-style: normal; font-size: .85rem; color: var(--muted); }
.af-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.af-tag { font-size: .75rem; padding: 2px 9px; border-radius: 999px; background: #2a1f17; border: 1px solid var(--line); color: #cdb9a2; }
.af-tag.fire { color: var(--fire); } .af-tag.frost, .af-tag.cold { color: var(--frost); } .af-tag.shadow { color: var(--shadow); }
.af-tag.holy { color: var(--holy); } .af-tag.phys { color: #d6d0c8; }

.af-skill { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 16px 18px; margin: 14px 0; }
.af-skill h3 { margin: 0; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.af-skill h3 small { font: 500 .9rem var(--body); color: var(--muted); }
.af-skill p { margin: 6px 0 10px; }
.af-skill .table-scroll { margin: 8px 0 0; }
.af-skill.asc { border-color: #5a4126; background: linear-gradient(180deg, #241a10, var(--panel)); }

.r1 { color: var(--magic); } .r2 { color: var(--rare); } .r3 { color: var(--unique); }
.af-item { border: 1px solid #4a3220; border-radius: 10px; background: #150f0b; padding: 14px 16px; text-align: center; }
.af-item h4 { margin: 0; font-family: var(--head); color: var(--unique); font-size: 1.05rem; }
.af-item .base { color: var(--muted); font-size: .8rem; margin-bottom: 8px; }
.af-item ul { list-style: none; margin: 0; padding: 8px 0; border-top: 1px solid #2c2219; color: var(--magic); font-size: .88rem; }
.af-item .flavor { color: #c6863f; font-style: italic; font-size: .85rem; margin-top: 6px; }
.af-item .from { color: var(--gold); font-size: .78rem; margin-top: 8px; }
.af-orb { display: inline-flex; width: 30px; height: 30px; border-radius: 50%; align-items: center; justify-content: center; color: #120b06; font-weight: 700; box-shadow: 0 0 12px currentColor; vertical-align: middle; }
.af-orb i { font-style: normal; color: #120b06; }

.af-note { background: #1e1a12; border: 1px solid #4a3d22; border-radius: 10px; padding: 12px 16px; color: #d9c9a8; margin: 1em 0 1.6em; }
.af-cta { text-align: center; padding: 40px 20px; margin: 3em 0 0; border: 1px solid var(--line); border-radius: 16px; background: radial-gradient(ellipse at 50% 120%, #4a1d0a, var(--panel) 70%); }
.af-cta h2 { border: 0; margin-top: 0; }

/* ---------- news ---------- */
.post-list { display: grid; gap: 16px; }
.post-item { border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; background: var(--panel); }
.post-item h2 { border: 0; margin: 0 0 4px; font-size: 1.3rem; }
.post-item .post-meta { margin-bottom: 8px; }
.pagination { margin-top: 24px; display: flex; gap: 8px; }
.pagination .page-numbers { padding: 4px 12px; border: 1px solid var(--line); border-radius: 6px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 32px 0 40px; color: var(--muted); font-size: .85rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 16px 40px; justify-content: space-between; }
.site-footer a { color: #cdb9a2; }

/* the block editor's own wrappers inside generated content */
.content .wp-block-html { margin: 0; }
.screen-reader-text { position: absolute; left: -9999px; }

/* ---------- audio ---------- */
.af-vo {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin: 0 8px 0 0;
  border-radius: 50%; border: 1px solid var(--ember2); background: #2a160c; color: var(--ember); font-size: .75rem;
  cursor: pointer; vertical-align: middle; flex: none; font-style: normal; padding: 0 0 0 2px;
}
.af-vo:hover { background: #3b1d0d; }
.af-vo.playing { background: var(--ember); color: #1a0d05; animation: af-pulse 1s ease-in-out infinite; }
.af-quote .af-vo { float: left; margin: 2px 12px 4px 0; }
@keyframes af-pulse { 50% { box-shadow: 0 0 0 6px #ff7a2f30; } }
.af-music {
  position: fixed; right: 16px; bottom: 16px; z-index: 60; width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(29, 23, 18, .92); color: var(--muted); font-size: 1.3rem; cursor: pointer;
  box-shadow: 0 6px 20px #000a;
}
.af-music.on { color: var(--ember); border-color: var(--ember2); }
.af-music.on span { display: inline-block; animation: af-bob 1.2s ease-in-out infinite; }
@keyframes af-bob { 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .af-music.on span, .af-vo.playing { animation: none; } }
/* phones: wide tables scroll sideways inside their frame instead of squeezing Thai text into slivers */
@media (max-width: 640px) {
  .af-table.wide { min-width: 600px; }
  .af-table th, .af-table td { padding: 8px 10px; }
  .hero { min-height: 260px; }
}
/* letter-spacing splits Thai vowel and tone marks from their consonants */
html[lang^="th"] .hero .kicker, html[lang^="th"] h1, html[lang^="th"] h2, html[lang^="th"] h3 { letter-spacing: 0; }

/* guardian portrait (3D model render) beside its story */
.af-portrait { float: right; width: min(40%, 340px); margin: .3em 0 1em 1.4em; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #120d0a; }
.af-portrait img { display: block; width: 100%; height: auto; }
@media (max-width: 700px) { .af-portrait { float: none; width: 100%; max-width: 420px; margin: 1em auto; } }
.af-credit { color: var(--muted); font-size: .85rem; }
.af-clear { clear: both; }

.af-trailer { margin: 1em 0 .4em; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #000; box-shadow: 0 10px 40px rgba(255,90,20,.18); }
.af-trailer video { display: block; width: 100%; height: auto; aspect-ratio: 16/9; }
.af-trailer-note { color: #a89878; font-size: .85em; margin: 0 0 1.6em; text-align: center; }
