/* ==========================================================================
   Age of Towers — ageoftowers.com
   One stylesheet for every page. The CSP forbids inline styles entirely
   (style-src 'self', no unsafe-inline), so nothing here may move into markup.

   Palette and type are ported from the game's own design system
   (ios/AgeOfTowers/Views/DesignSystem.swift): "modern layout, medieval
   accents" — warm dark ground, brass accents, Cinzel inscriptional caps.
   ========================================================================== */

/* --- Fonts ---------------------------------------------------------------- */

@font-face {
  font-family: "Cinzel";
  src: url("../fonts/Cinzel-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  /* `block`, not `swap`: a fallback flash at display size reflows very
     visibly, because Cinzel's caps are far wider than the fallback stack. */
  font-display: block;
}

/* --- Tokens --------------------------------------------------------------- */

:root {
  /* Surfaces — AppColor.backdropTop / backdropBottom */
  --backdrop-top: #1a170f;
  --backdrop-bottom: #2e2110;
  --surface: #221d14;
  --surface-raised: #2a2318;

  /* Materials */
  --parchment: #ede0c7;
  --wood: #5c4026;
  --brass: #d4a338;
  --brass-light: #f5cc5c;

  /* Text — AppColor.ink / inkDim / inkFaint */
  --ink: #f5eddb;
  --ink-dim: rgba(245, 237, 219, 0.68);
  --ink-faint: rgba(245, 237, 219, 0.42);

  /* Rules */
  --rule: rgba(212, 163, 56, 0.22);
  --rule-strong: rgba(212, 163, 56, 0.42);
  --rule-quiet: rgba(245, 237, 219, 0.12);

  /* Age accents — AgeTheme, DesignSystem.swift:335-353 */
  --age-stone: #8c947f;
  --age-bronze: #c77a38;
  --age-iron: #a1abba;
  --age-medieval: #944c73;

  /* Type */
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Measure */
  --frame: 64rem;
  --prose: 38rem;

  color-scheme: dark;
}

/* --- Reset / base --------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--backdrop-top);
  /* Warm gradient ground + a fine grain overlay. The data: URI is permitted
     by `img-src 'self' data:`. Never a flat black, never a blue-black. */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E"),
    linear-gradient(175deg, var(--backdrop-top) 0%, var(--backdrop-bottom) 100%);
  background-attachment: scroll, fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- Typography ----------------------------------------------------------- */

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 700;
  color: var(--brass);
  /* Inscriptional Roman caps need air — the inverse of a modern grotesque. */
  text-transform: uppercase;
  letter-spacing: 0.075em;
  line-height: 1.08;
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.1rem, 6.2vw, 4rem);
  letter-spacing: 0.06em;
}

h2 {
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
}

h3 {
  font-size: 1.05rem;
  letter-spacing: 0.09em;
  color: var(--parchment);
}

p {
  margin: 0 0 1.1em;
}

a {
  color: var(--brass);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
  transition: color 0.15s ease, border-color 0.15s ease;
}

a:hover {
  color: var(--brass-light);
  border-bottom-color: var(--brass-light);
}

a:focus-visible {
  outline: 2px solid var(--brass-light);
  outline-offset: 3px;
  border-radius: 2px;
}

strong {
  color: var(--parchment);
  font-weight: 600;
}

/* Uppercase micro-label, used for eyebrows and spec keys. */
.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--brass);
  margin: 0 0 0.9rem;
}

.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}

.lede {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  line-height: 1.55;
  color: var(--ink-dim);
  max-width: 34rem;
}

/* --- Layout --------------------------------------------------------------- */

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

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
  background: var(--surface-raised);
  padding: 0.6rem 1rem;
  border: 1px solid var(--brass);
}

section {
  padding: clamp(3rem, 7vw, 5.5rem) 0;
  border-top: 1px solid var(--rule-quiet);
}

section:first-of-type {
  border-top: 0;
}

/* The icon's concentric brass-ring motif, reused as a section divider. */
.ring-rule {
  display: block;
  width: 100%;
  max-width: var(--frame);
  margin: 0 auto;
  height: 1px;
  border: 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--rule-strong) 22%,
    var(--brass) 50%,
    var(--rule-strong) 78%,
    transparent
  );
}

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

.site-header {
  border-bottom: 1px solid var(--rule-quiet);
}

.site-header .frame {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
  flex-wrap: wrap;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--display);
  font-size: 0.98rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--parchment);
  border-bottom: 0;
}

.wordmark:hover {
  color: var(--brass);
}

.wordmark img {
  width: 30px;
  height: 30px;
  border-radius: 7px;
}

.site-nav {
  display: flex;
  gap: 1.4rem;
  font-size: 0.88rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--ink-dim);
  border-bottom: 0;
}

.site-nav a:hover {
  color: var(--brass);
}

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2.75rem 0 3.5rem;
  font-size: 0.87rem;
  color: var(--ink-faint);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  margin-bottom: 1.5rem;
}

.site-footer p {
  margin: 0 0 0.5rem;
  max-width: 46rem;
}

/* --- Hero ----------------------------------------------------------------- */

.hero {
  padding: clamp(3rem, 9vw, 6.5rem) 0 clamp(2.5rem, 6vw, 4rem);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.hero-art {
  position: relative;
  display: flex;
  justify-content: center;
  /* The glow below is inset negatively; without this it widens the page. */
  overflow: hidden;
  padding: 14% 0;
}

/* A single faint brass light source behind the icon — not decoration. */
.hero-art::before {
  content: "";
  position: absolute;
  inset: -14%;
  background: radial-gradient(
    circle at 50% 45%,
    rgba(212, 163, 56, 0.16),
    transparent 62%
  );
  pointer-events: none;
}

.hero-art img {
  position: relative;
  width: min(300px, 100%);
  border-radius: 26px;
}

.hero .lede {
  margin-top: 1.4rem;
}

.hero-meta {
  margin-top: 1.75rem;
}

/* --- Buttons -------------------------------------------------------------- */

.cta-row {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.btn {
  display: inline-block;
  font-family: var(--display);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  padding: 0.85rem 1.7rem;
  border-radius: 3px;
  border: 1px solid var(--brass);
  color: var(--backdrop-top);
  background: linear-gradient(180deg, var(--brass-light), var(--brass));
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.btn:hover {
  color: var(--backdrop-top);
  box-shadow: 0 0 26px rgba(212, 163, 56, 0.34);
  transform: translateY(-1px);
}

/* The App Store link cannot exist until the app is approved. Rendered as a
   non-link so it can never 404 in front of a reviewer. */
.btn-pending {
  display: inline-block;
  font-family: var(--display);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  padding: 0.85rem 1.7rem;
  border-radius: 3px;
  border: 1px dashed var(--rule-strong);
  color: var(--ink-faint);
  background: transparent;
}

/* --- Age band ------------------------------------------------------------- */

.age-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.age {
  border-top: 2px solid var(--age-accent, var(--brass));
  padding-top: 1.15rem;
  transition: transform 0.2s ease;
}

.age:hover {
  transform: translateY(-3px);
}

/* Per-age theming MUST be class-driven: `style="--age-accent:…"` would be
   blocked by style-src 'self', and only on the live domain. */
.age--stone {
  --age-accent: var(--age-stone);
}
.age--bronze {
  --age-accent: var(--age-bronze);
}
.age--iron {
  --age-accent: var(--age-iron);
}
.age--medieval {
  --age-accent: var(--age-medieval);
}

/* The four sprites have different intrinsic proportions; a fixed box with
   `contain` makes them read at a consistent optical size and keeps the
   age headings on a common baseline. */
.age img {
  width: 100%;
  height: 132px;
  object-fit: contain;
  object-position: center bottom;
  margin: 0 auto 1rem;
}

.age h3 {
  color: var(--age-accent, var(--brass));
  margin-bottom: 0.4rem;
}

.age p {
  font-size: 0.9rem;
  color: var(--ink-dim);
  margin: 0;
}

.age .unlock {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--ink-faint);
  display: block;
  margin-top: 0.6rem;
}

/* --- Feature columns ------------------------------------------------------ */

.cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.6rem;
  margin-top: 2.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule-quiet);
  border-radius: 14px;
  padding: 1.6rem;
}

.card img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  object-position: left bottom;
  margin-bottom: 1rem;
}

.card h3 {
  margin-bottom: 0.55rem;
}

.card p {
  font-size: 0.92rem;
  color: var(--ink-dim);
  margin: 0;
}

/* --- Enemy row ------------------------------------------------------------ */

.enemy-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.25rem;
  margin-top: 2.5rem;
}

.enemy {
  text-align: center;
}

.enemy img {
  width: 100%;
  height: 76px;
  object-fit: contain;
  object-position: center bottom;
  margin: 0 auto 0.7rem;
}

.enemy span {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

/* --- Screenshots ---------------------------------------------------------- */

.shots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.4rem;
  margin-top: 2.5rem;
}

.shots figure {
  margin: 0;
}

.shots img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--rule);
  background: var(--surface);
  /* Device screenshots are dark; a soft lift separates them from the ground. */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 32px -18px rgba(0, 0, 0, 0.75);
}

.shots figcaption {
  margin-top: 0.8rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-faint);
}

/* --- Spec table ----------------------------------------------------------- */

.specs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 2.5rem;
  background: var(--rule-quiet);
  border: 1px solid var(--rule-quiet);
}

.spec {
  background: var(--backdrop-top);
  padding: 1.3rem 1rem;
  text-align: center;
}

.spec b {
  display: block;
  font-family: var(--mono);
  font-size: 1.65rem;
  font-weight: 400;
  color: var(--brass);
  line-height: 1.1;
}

.spec span {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--ink-faint);
}

/* --- Privacy panel -------------------------------------------------------- */

.panel {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--brass);
  border-radius: 4px;
  background: var(--surface);
  padding: clamp(1.5rem, 3.5vw, 2.4rem);
  margin-top: 2rem;
}

.panel ul {
  list-style: none;
  margin: 1.2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem 1.5rem;
}

.panel li {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-dim);
  padding-left: 1.3rem;
  position: relative;
}

.panel li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--brass);
}

/* --- Pricing -------------------------------------------------------------- */

.tiers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.6rem;
  margin-top: 2.5rem;
}

.tier {
  border: 1px solid var(--rule-quiet);
  border-radius: 14px;
  padding: 1.8rem;
  background: var(--surface);
}

.tier--paid {
  border-color: var(--rule-strong);
}

.tier ul {
  margin: 1rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.92rem;
  color: var(--ink-dim);
}

.tier li {
  margin-bottom: 0.4rem;
}

.price {
  font-family: var(--mono);
  font-size: 1.35rem;
  color: var(--brass);
  display: block;
  margin: 0.5rem 0 0.2rem;
}

/* "incl. VAT" must sit in the SAME block as the figure (§ 6(1) Nr. 1 PAngV),
   so it is part of .price rather than a detached footnote. */
.price em {
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.8rem;
  color: var(--ink-dim);
  letter-spacing: 0.01em;
}

.price-note {
  font-size: 0.8rem;
  color: var(--ink-faint);
  display: block;
}

/* Mandatory price disclosures — quiet, but on the same page and viewport as
   the price it qualifies. Never move this to a separate legal page. */
.price-legal {
  margin: 1.6rem 0 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink-faint);
  max-width: 46rem;
}

/* --- Prose (legal pages) -------------------------------------------------- */

.prose {
  max-width: var(--prose);
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 4rem) 1.75rem clamp(3rem, 7vw, 5rem);
  font-size: 1.02rem;
}

.prose h1 {
  font-size: clamp(1.7rem, 4.5vw, 2.5rem);
  margin-bottom: 1rem;
}

.prose h2 {
  font-size: 1.02rem;
  letter-spacing: 0.1em;
  color: var(--brass);
  margin: 2.6rem 0 0.85rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule-quiet);
}

.prose h3 {
  font-size: 0.92rem;
  margin: 1.7rem 0 0.6rem;
  letter-spacing: 0.07em;
}

.prose p,
.prose li {
  color: var(--ink-dim);
}

.prose ul,
.prose ol {
  padding-left: 1.2rem;
  margin: 0 0 1.1em;
}

.prose li {
  margin-bottom: 0.45rem;
}

.doc-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--rule-quiet);
  margin-bottom: 1.8rem;
}

/* A bordered block for controller/company details. */
.detail-block {
  border: 1px solid var(--rule-quiet);
  border-radius: 10px;
  background: var(--surface);
  padding: 1.3rem 1.5rem;
  margin: 0 0 1.4rem;
  font-size: 0.94rem;
  line-height: 1.75;
}

.detail-block .mono {
  display: block;
  font-size: 0.78rem;
}

/* The "at a glance" summary that opens the privacy policy. */
.summary {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--brass);
  border-radius: 4px;
  background: var(--surface);
  padding: 1.4rem 1.6rem;
  margin-bottom: 2rem;
}

.summary p:last-child {
  margin-bottom: 0;
}

/* German controlling-language block on the Impressum. */
.lang-note {
  font-size: 0.87rem;
  color: var(--ink-faint);
  border-left: 2px solid var(--rule);
  padding-left: 1rem;
  margin-bottom: 2rem;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .hero-art {
    order: -1;
  }

  .hero-art img {
    width: min(210px, 60%);
  }

  .cols,
  .tiers {
    grid-template-columns: 1fr;
  }

  .age-grid,
  .specs {
    grid-template-columns: repeat(2, 1fr);
  }

  .enemy-row {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Five phone screenshots don't fit side by side below desktop; scroll them
     horizontally inside their own container rather than shrinking them to
     illegibility. The page body itself never scrolls sideways. */
  .shots {
    grid-template-columns: repeat(5, 62vw);
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 0.75rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .shots figure {
    scroll-snap-align: start;
  }
}

@media (max-width: 560px) {
  .shots {
    grid-template-columns: repeat(5, 78vw);
  }
}

@media (max-width: 560px) {
  .age-grid,
  .specs {
    grid-template-columns: 1fr 1fr;
  }

  /* Keep the five-strong roster on a single row rather than orphaning the
     boss on a line of its own. */
  .enemy-row {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
  }

  .enemy img {
    height: 52px;
  }

  .enemy span {
    font-size: 0.56rem;
    letter-spacing: 0.04em;
  }

  .panel ul {
    grid-template-columns: 1fr;
  }

  .site-header .frame {
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
