/* =========================================================
   Piglets — shared styles
   Design: hand-painted farmyard signage. Fence-post gates,
   swinging signs, pig-ear notch cards.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700;9..144,900&family=Karla:wght@400;500;600;700&display=swap');

:root {
  --bg: #EBEFE1;
  --bg-soft: #F4F1E6;
  --card: #FBF8F0;
  --ink: #2B2420;
  --ink-soft: #5B5346;
  --pink: #D97A88;
  --pink-deep: #B8556A;
  --green: #6B7F5E;
  --green-deep: #48573D;
  --mustard: #E3A857;
  --wood: #A9784F;
  --wood-deep: #7C5636;
  --white: #FFFDF9;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Karla', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius: 14px;
  --shadow-sign: 0 10px 22px -10px rgba(43, 36, 32, 0.35);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  /* the pig-flag wiggle is a small, subtle rotation (not a large or
     disorienting motion), so it keeps running even when the device
     requests reduced motion */
  .flag-wiggle { animation-duration: 3.4s !important; animation-iteration-count: infinite !important; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(227, 168, 87, 0.16), transparent),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(217, 122, 136, 0.14), transparent),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
}

a { color: inherit; }

/* ---------- Fence rail top/bottom decoration ---------- */

.fence-rail {
  height: 14px;
  background:
    repeating-linear-gradient(
      90deg,
      var(--wood) 0px, var(--wood) 3px,
      transparent 3px, transparent 34px
    ),
    linear-gradient(var(--wood-deep), var(--wood-deep));
  background-size: 34px 14px, 100% 6px;
  background-position: 0 0, 0 100%;
  background-repeat: repeat-x, no-repeat;
  opacity: 0.9;
}

/* ---------- Focus visibility ---------- */

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--green-deep);
  outline-offset: 3px;
  border-radius: 6px;
}

/* =========================================================
   Landing page
   ========================================================= */

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.landing-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6vh 5vw 8vh;
  text-align: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.brand-piglet {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
  line-height: 1;
}

.brand-title .dot {
  color: var(--pink-deep);
}

.landing-tagline {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--ink-soft);
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  letter-spacing: 0.01em;
  margin: 0 0 4.5rem;
  max-width: 46ch;
}

.gate-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(1rem, 3vw, 2.2rem);
  width: 100%;
  max-width: 980px;
}

@media (max-width: 720px) {
  .gate-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 2.6rem;
  }
}

.sign-link {
  text-decoration: none;
  display: block;
  outline-offset: 6px;
}

.sign {
  --tilt: 0deg;
  position: relative;
  background: var(--card);
  border-radius: 10px;
  padding: 1.6rem 1rem 1.3rem;
  box-shadow: var(--shadow-sign);
  transform: rotate(var(--tilt));
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  border: 3px solid var(--wood-deep);
}

.sign::before {
  /* rope/nail hanging the sign from the rail above */
  content: '';
  position: absolute;
  top: -22px;
  left: 50%;
  width: 3px;
  height: 24px;
  background: var(--wood-deep);
  transform: translateX(-50%) rotate(calc(var(--tilt) * -1));
  transform-origin: bottom center;
  opacity: 0.7;
}

.sign-link:hover .sign,
.sign-link:focus-visible .sign {
  transform: rotate(0deg) translateY(-6px);
  box-shadow: 0 18px 30px -12px rgba(43, 36, 32, 0.4);
}

.sign-flag {
  width: 100%;
  height: 100%;
  display: block;
}

.flag-wiggle {
  display: block;
}

.sign-link .flag-wiggle {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(43, 36, 32, 0.25);
  background: var(--white);
}

.lang-pill .flag-wiggle {
  width: 100%;
  height: 100%;
}

.sign-label {
  display: block;
  margin-top: 0.85rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
}

.sign-sub {
  display: block;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 0.15rem;
}

.landing-footer {
  text-align: center;
  padding: 1.2rem 1rem 1.6rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* =========================================================
   Rules page
   ========================================================= */

.rules-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.rules-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  flex-wrap: wrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--white);
  background: var(--green-deep);
  padding: 0.55rem 1rem 0.55rem 0.8rem;
  border-radius: 999px;
  box-shadow: var(--shadow-sign);
  transition: transform 0.2s ease, background 0.2s ease;
}

.back-link:hover,
.back-link:focus-visible {
  background: var(--green);
  transform: translateX(-3px);
}

.lang-switch {
  display: flex;
  gap: 0.5rem;
}

.lang-pill {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-sign);
  display: block;
  text-decoration: none;
  transition: transform 0.2s ease;
  background: var(--white);
}

.lang-pill:hover,
.lang-pill:focus-visible {
  transform: translateY(-3px);
}

.lang-pill.current {
  border-color: var(--ink);
  transform: scale(1.12);
}

.rules-main {
  flex: 1;
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 4rem;
  display: flex;
  justify-content: center;
}

.rules-sheet {
  width: 100%;
  max-width: 760px;
}

.rules-hero {
  text-align: center;
  margin-bottom: 2.4rem;
}

.rules-hero .flag-wiggle {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(43, 36, 32, 0.25);
  box-shadow: var(--shadow-sign);
  background: var(--white);
}

.rules-flag-chip {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Gentle pig-flag wiggle ---------- */

@keyframes pig-wiggle {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.flag-wiggle {
  animation: pig-wiggle 3.4s ease-in-out infinite;
  transform-origin: 50% 88%;
  will-change: transform;
}

.gate-row .sign-link:nth-child(1) .flag-wiggle { animation-delay: -0.2s; }
.gate-row .sign-link:nth-child(2) .flag-wiggle { animation-delay: -1.1s; }
.gate-row .sign-link:nth-child(3) .flag-wiggle { animation-delay: -2s; }
.gate-row .sign-link:nth-child(4) .flag-wiggle { animation-delay: -2.9s; }

.lang-switch .lang-pill:nth-child(1) .flag-wiggle { animation-delay: -0.4s; }
.lang-switch .lang-pill:nth-child(2) .flag-wiggle { animation-delay: -1.3s; }
.lang-switch .lang-pill:nth-child(3) .flag-wiggle { animation-delay: -2.2s; }
.lang-switch .lang-pill:nth-child(4) .flag-wiggle { animation-delay: -3.1s; }

.rules-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.1rem, 6vw, 3.1rem);
  margin: 0 0 0.4rem;
  letter-spacing: -0.01em;
}

.rules-subtitle {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0;
  font-size: 1rem;
}

.rules-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid rgba(169, 120, 79, 0.35);
  box-shadow: var(--shadow-sign);
  padding: clamp(1.4rem, 4vw, 2.2rem);
  margin-bottom: 1.4rem;
  position: relative;
}

/* pig-ear notch corner */
.rules-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 26px;
  height: 26px;
  background: var(--bg);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  border-bottom: 1px solid rgba(169, 120, 79, 0.35);
  border-left: 1px solid rgba(169, 120, 79, 0.35);
}

.rules-card h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  margin: 0 0 0.85rem;
  color: var(--pink-deep);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.rules-card h2 .num {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--white);
  background: var(--green-deep);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rules-card p {
  margin: 0 0 0.8rem;
  color: var(--ink);
}
.rules-card p:last-child { margin-bottom: 0; }

.rules-card ul {
  margin: 0 0 0.8rem;
  padding-left: 0;
  list-style: none;
}

.rules-card ul:last-child { margin-bottom: 0; }

.rules-card li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.55rem;
}

.rules-card li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.42em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mustard);
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
}

.score-table th,
.score-table td {
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid rgba(169, 120, 79, 0.3);
}

.score-table th {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--green-deep);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.score-table td.pts {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--pink-deep);
  white-space: nowrap;
}

/* ---------- Illustrated score list ---------- */

.score-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 0.8rem;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--white);
  border: 1px solid rgba(169, 120, 79, 0.3);
  border-radius: 10px;
  padding: 0.6rem 1rem 0.6rem 0.6rem;
}

.score-thumb {
  width: 84px;
  height: 62px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid rgba(43, 36, 32, 0.2);
  flex-shrink: 0;
  background: #EFEFEF;
}

.score-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  flex: 1;
}

.score-pts {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--pink-deep);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .score-thumb { width: 64px; height: 48px; }
  .score-name { font-size: 0.92rem; }
  .score-pts { font-size: 0.95rem; }
}

/* ---------- Illustrated score grid (2x2) ---------- */

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.score-tile {
  background: var(--white);
  border: 1px solid rgba(169, 120, 79, 0.3);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.score-thumb-lg {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #EFEFEF;
  border-bottom: 1px solid rgba(169, 120, 79, 0.3);
}

.score-tile-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
}

.score-tile-caption .score-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

.score-tile-caption .score-pts {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--pink-deep);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .score-tile-caption .score-name { font-size: 0.85rem; }
  .score-tile-caption .score-pts { font-size: 0.88rem; }
  .score-tile-caption { padding: 0.5rem 0.6rem; }
}

/* ---------- Bust callout ---------- */

.bust-callout {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  background: #FBE2E2;
  border: 1px dashed var(--pink-deep);
  border-radius: 10px;
  padding: 0.9rem 1.2rem;
  margin-top: 1rem;
}

.bust-thumb {
  width: 150px;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(43, 36, 32, 0.2);
  flex-shrink: 0;
  background: #EFEFEF;
}

.bust-text p {
  margin: 0 0 0.3rem;
}
.bust-text p:last-child { margin-bottom: 0; }

.bust-text strong {
  color: var(--pink-deep);
}

@media (max-width: 480px) {
  .bust-callout { flex-direction: column; text-align: center; }
}

.rules-footer {
  text-align: center;
  padding: 1rem 1rem 1.6rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

@media (max-width: 480px) {
  .rules-card h2 { font-size: 1.2rem; }
  .score-table { font-size: 0.85rem; }
}
