/* PurpleFox — paper style
   Colours, fonts and sizes live in :root; change them there. */

/* Fonts, self-hosted (SIL Open Font License): Nunito, Patrick Hand. Latin subset (covers Italian). */
@font-face {
  font-family: "Nunito";
  src: url("../fonts/nunito-latin.woff2") format("woff2");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Patrick Hand";
  src: url("../fonts/patrick-hand-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f5efe3;
  --paper-card: #fffdf7;
  --ink: #2a2338;
  --ink-soft: #5c5470;
  --purple: #6a3fa0;
  --purple-deep: #4b2a78;
  --purple-wash: #e9def7;
  --fox: #e57a2e;
  --tape: rgba(229, 122, 46, 0.35);
  --line: rgba(106, 63, 160, 0.14);

  --font-hand: "Patrick Hand", "Comic Sans MS", cursive;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius: 6px;
  --wrap: 1080px;
  --shadow: 0 1px 1px rgba(42, 35, 56, 0.08), 0 6px 18px rgba(42, 35, 56, 0.10);
  --shadow-lift: 0 2px 2px rgba(42, 35, 56, 0.08), 0 14px 30px rgba(42, 35, 56, 0.16);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  /* paper grain */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.28 0 0 0 0 0.2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

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

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

h1, h2, h3 {
  font-family: var(--font-hand);
  font-weight: 400;
  line-height: 1.1;
  color: var(--ink);
  margin: 0 0 .4em;
}
h1 { font-size: clamp(2.6rem, 6vw, 4.2rem); }
h2 { font-size: clamp(2rem, 4vw, 2.8rem); }
h3 { font-size: 1.7rem; }

.wrap { width: min(var(--wrap), 100% - 2.5rem); margin-inline: auto; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 10; background: var(--paper-card); padding: .5rem 1rem; }

:focus-visible { outline: 3px dashed var(--fox); outline-offset: 3px; }

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

.site-header { padding: 1.25rem 0; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.brand img { width: 52px; height: 52px; transform: rotate(-6deg); }
.brand span { font-family: var(--font-hand); font-size: 2rem; line-height: 1; }
.brand b { color: var(--purple); font-weight: 400; }

.nav { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.nav a {
  font-family: var(--font-hand);
  font-size: 1.35rem;
  text-decoration: none;
  color: var(--ink);
  padding: .15rem .8rem;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px; /* wobbly */
  border: 2px solid transparent;
}
.nav a:hover, .nav a[aria-current="page"] { border-color: var(--ink); background: var(--paper-card); }

/* CraftPages language switcher (markup is the app's; only restyled here) */
.nav .craftpages-languages {
  order: 99; /* after the menu links, wherever it's placed */
  margin-left: .3rem; padding-left: .7rem;
  border-left: 2px dashed var(--line);
  --craftpages-languages-bg: var(--paper-card);
  --craftpages-languages-fg: var(--ink);
}
.nav .craftpages-languages summary {
  font-family: var(--font-hand); font-size: 1.35rem; line-height: 1.6; font-weight: 400 !important;
  padding: .15rem .6rem !important;
  border: 2px solid transparent !important;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px !important;
}
.nav .craftpages-languages summary:hover,
.nav .craftpages-languages details[open] summary { border-color: var(--ink) !important; background: var(--paper-card) !important; }
.nav .craftpages-languages img { box-shadow: 0 0 0 1px rgba(42, 35, 56, .15); }
.nav .craftpages-languages ul {
  border: 2px solid var(--ink);
  border-radius: 6px !important;
  box-shadow: 3px 3px 0 var(--ink) !important;
}
.nav .craftpages-languages li a {
  font-family: var(--font-hand); font-size: 1.3rem;
  border: 0; border-radius: 4px !important;
}
.nav .craftpages-languages li a:hover,
.nav .craftpages-languages li a:focus-visible { background: var(--purple-wash); color: var(--ink); }

/* ---------- hero ---------- */

.hero { padding: 2.5rem 0 3.5rem; }
.hero .wrap { display: grid; grid-template-columns: 1.2fr 1fr; gap: 2.5rem; align-items: center; }
.hero p.lead { font-size: 1.25rem; color: var(--ink-soft); max-width: 34ch; }
.hero .scribble { color: var(--purple); position: relative; white-space: nowrap; }
.hero .scribble::after { /* hand-drawn underline */
  content: ""; position: absolute; left: -4px; right: -4px; bottom: -6px; height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 12' preserveAspectRatio='none'%3E%3Cpath d='M2 8 C40 2 80 11 120 5 S180 3 198 7' fill='none' stroke='%23e57a2e' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
}
.hero-art { justify-self: center; transform: rotate(3deg); }
.hero-art img { width: min(380px, 72vw); height: auto; filter: drop-shadow(0 12px 20px rgba(42,35,56,.22)); }

@media (max-width: 760px) {
  .hero .wrap { grid-template-columns: 1fr; text-align: center; }
  .hero p.lead { margin-inline: auto; }
  .hero-art { order: -1; }
  .hero .btns { justify-content: center; }
}

/* ---------- buttons ---------- */

.btns { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 1.5rem; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-hand); font-size: 1.45rem; line-height: 1;
  padding: .65rem 1.4rem;
  color: #fff; background: var(--purple);
  border: 2px solid var(--ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  box-shadow: 3px 3px 0 var(--ink);
  text-decoration: none; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { color: #fff; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.ghost { background: var(--paper-card); color: var(--ink); }
.btn.ghost:hover { color: var(--ink); }

/* ---------- sections ---------- */

.section { padding: 3rem 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.section-head p { margin: 0; color: var(--ink-soft); }

/* ---------- game cards (index cards with tape) ---------- */

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2.2rem 2rem; }

.card {
  position: relative;
  background: var(--paper-card);
  padding: 1rem 1rem 1.3rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: rotate(var(--tilt, -1deg));
  transition: transform .2s ease, box-shadow .2s ease;
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column;
}
.card:nth-child(3n+2) { --tilt: 1.2deg; }
.card:nth-child(3n+3) { --tilt: -.4deg; }
.card:hover { transform: rotate(0deg) translateY(-4px); box-shadow: var(--shadow-lift); color: inherit; }

.card::before { /* tape */
  content: ""; position: absolute; top: -12px; left: 50%;
  width: 96px; height: 26px; margin-left: -48px;
  background: var(--tape);
  transform: rotate(-3deg);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.card:nth-child(even)::before { transform: rotate(4deg); background: rgba(106, 63, 160, 0.25); }

.card .cover {
  aspect-ratio: 16 / 10; width: 100%; height: auto; object-fit: cover;
  border-radius: 3px; background: var(--purple-wash);
  border: 1px solid var(--line);
}
.card h3 { margin: .8rem 0 .2rem; }
.card p { margin: 0; color: var(--ink-soft); }
.card .meta { margin-top: auto; padding-top: .9rem; display: flex; gap: .4rem; flex-wrap: wrap; }

.tag {
  font-family: var(--font-hand); font-size: 1.05rem; line-height: 1;
  padding: .25rem .6rem; border: 1.5px solid var(--ink-soft); color: var(--ink-soft);
  border-radius: 999px;
}
.tag.new { border-color: var(--fox); color: var(--fox); }

/* ---------- lined note (about, info boxes) ---------- */

.note {
  position: relative;
  background-color: var(--paper-card);
  background-image: linear-gradient(transparent calc(1.7em - 1px), var(--line) calc(1.7em - 1px));
  background-size: 100% 1.7em;
  line-height: 1.7em;
  padding: 1.7em 1.8rem 1.7em 3.2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.note::before { /* red margin line */
  content: ""; position: absolute; top: 0; bottom: 0; left: 2.2rem;
  width: 2px; background: rgba(229, 122, 46, .45);
}
.note p { margin: 0 0 1.7em; }
.note p:last-child { margin-bottom: 0; }
.note h2, .note h3 { line-height: 1.7em; margin: 0 0 .2em; }

/* ---------- game page ---------- */

.game-head { padding: 1.5rem 0 1rem; }
.game-head .back { font-family: var(--font-hand); font-size: 1.25rem; text-decoration: none; }
.game-head p { color: var(--ink-soft); font-size: 1.2rem; margin: 0; }

.stage {
  position: relative;
  background: var(--paper-card);
  padding: .8rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
}
.stage-frame {
  position: relative;
  aspect-ratio: var(--ratio, 1.7778);
  /* never taller than the screen: shrink the width instead */
  width: min(100%, calc((100vh - 9rem) * var(--ratio, 1.7778)));
  margin-inline: auto;
  background: #1b1626;
  border-radius: 3px;
  overflow: hidden;
}
.stage-frame:fullscreen { width: 100%; aspect-ratio: auto; border-radius: 0; }
.stage-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.stage-start {
  position: absolute; inset: 0;
  display: grid; place-items: center; align-content: center; gap: 1rem;
  background: center / cover no-repeat var(--cover, none), #1b1626;
  border: 0; cursor: pointer; color: #fff; width: 100%;
}
.stage-start::before { content: ""; position: absolute; inset: 0; background: rgba(27, 22, 38, .45); }
.stage-start > * { position: relative; }
.stage-start .play-dot {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--fox); border: 3px solid #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  transition: transform .15s ease;
}
.stage-start:hover .play-dot { transform: scale(1.08); }
.stage-start .play-dot::after {
  content: ""; margin-left: 8px;
  border-style: solid; border-width: 18px 0 18px 30px;
  border-color: transparent transparent transparent #fff;
}
.stage-start span { font-family: var(--font-hand); font-size: 1.8rem; text-shadow: 0 2px 6px rgba(0,0,0,.5); }

.stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem .2rem 0; flex-wrap: wrap; }
.stage-bar small { color: var(--ink-soft); }
.stage-bar .btn { font-size: 1.2rem; padding: .45rem 1rem; }

.game-info { display: grid; grid-template-columns: 1.4fr 1fr; gap: 2rem; padding: 2.5rem 0 1rem; }
@media (max-width: 760px) { .game-info { grid-template-columns: 1fr; } }

.keys { list-style: none; padding: 0; margin: 0; }
.keys li { display: flex; align-items: center; gap: .6rem; }
kbd {
  font-family: var(--font-hand); font-size: 1.1rem;
  min-width: 2em; text-align: center;
  padding: 0 .45em; background: var(--paper);
  border: 1.5px solid var(--ink); border-bottom-width: 3px; border-radius: 5px;
}

/* ---------- screenshots (taped photos) ---------- */

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.8rem; padding: 1rem 0 0; }
.gallery a {
  position: relative; display: block;
  background: var(--paper-card); padding: .6rem .6rem 1.6rem;
  box-shadow: var(--shadow);
  transform: rotate(var(--tilt, 1.2deg));
  transition: transform .2s ease, box-shadow .2s ease;
}
.gallery a:nth-child(even) { --tilt: -1.4deg; }
.gallery a:hover { transform: rotate(0) scale(1.02); box-shadow: var(--shadow-lift); }
.gallery a::before {
  content: ""; position: absolute; top: -10px; left: 50%; width: 70px; height: 22px; margin-left: -35px;
  background: var(--tape); transform: rotate(-4deg);
}
.gallery img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }

.hint {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-hand); font-size: 1.15rem; color: var(--ink-soft);
  border: 1.5px dashed var(--ink-soft); border-radius: 999px; padding: .15rem .8rem; margin-top: .6rem;
}
.tag.scary { border-color: #b3261e; color: #b3261e; }

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

.site-footer { padding: 2.5rem 0 2rem; margin-top: 3rem; border-top: 2px dashed var(--line); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--ink-soft); }
.site-footer p { margin: 0; }
.site-footer .fox { font-family: var(--font-hand); font-size: 1.3rem; }

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