/* Fern Golf — the design system.
   One look for everything a player sees: the menus, the in-play HUD and the
   dialogs. The rules, all of them:

   - No outlines. A thing you can press is a flat, bright shape with a darker
     edge of its own colour underneath (the "lip"), like the side of a course
     block. Pressing it sinks it onto the lip.
   - A thing you only read sits on a white panel with a pale lip and a soft
     shadow.
   - Fredoka (rounded) is the voice: names, numbers, buttons. Figtree is the
     small print. Sentence case; capitals only for tiny labels.
   - Colour means something: green is go and good, gold is reward, coral is
     attention, blue is information, grape is collecting.

   Loaded first. css/game.css (the course and what floats over it) and
   css/menu.css (the pages) build only on what is defined here. The editors
   have their own stylesheets and do not use this file. */

@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../assets/fonts/fredoka.woff2") format("woff2");
}
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("../assets/fonts/figtree.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --font-display: "Fredoka", "Figtree", "Segoe UI", system-ui, sans-serif;
  --font-ui: "Figtree", "Segoe UI", system-ui, sans-serif;

  /* Ink and surfaces */
  --ink: #17332b;
  --ink-2: #557067;
  --ink-3: #8ea39b;
  --surface: #ffffff;
  --surface-2: #eff5f2;
  --lip: #d1dfd8;
  --line: #e4ece8;

  /* Colours: each has a face, a lip, a soft tint and an ink for text on the tint. */
  --green: #35c667;  --green-lip: #1f9a49;  --green-soft: #def6e7;  --green-ink: #12793a;
  --gold: #ffcb3d;   --gold-lip: #e0a008;   --gold-soft: #fff2c6;   --gold-ink: #8a5c00;
  --blue: #45b6f7;   --blue-lip: #1f8fd6;   --blue-soft: #dff1fe;   --blue-ink: #0f6aa8;
  --coral: #ff7262;  --coral-lip: #dc4b3c;  --coral-soft: #ffe5e1;  --coral-ink: #b3291b;
  --grape: #9a7bff;  --grape-lip: #7353e0;  --grape-soft: #ece6ff;  --grape-ink: #5a3bc7;

  /* Shape */
  --r-panel: 22px;
  --r-btn: 16px;
  --r-tile: 14px;
  --shadow-panel: 0 4px 0 var(--lip), 0 14px 28px rgba(23, 51, 43, 0.13);
  --shadow-float: 0 3px 0 rgba(23, 51, 43, 0.14), 0 10px 22px rgba(23, 51, 43, 0.18);
  --page-sky: linear-gradient(180deg, #aee0ff 0%, #d6f1ff 46%, #eefaf0 100%);

  /* Sizes. Phones in landscape are short, so the defaults are compact and a
     roomy screen (below) scales them up. */
  --tap: 44px;
  --gap: 12px;
  --pad: 16px;
  --fs-title: 22px;
  --fs-head: 17px;
  --fs-body: 14px;
  --fs-small: 12px;
  --fs-label: 10.5px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  font-family: var(--font-ui);
}
@media (min-width: 900px) and (min-height: 600px) {
  :root {
    --tap: 50px;
    --gap: 16px;
    --pad: 24px;
    --r-panel: 26px;
    --fs-title: 28px;
    --fs-head: 20px;
    --fs-body: 16px;
    --fs-small: 13.5px;
    --fs-label: 11.5px;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #cfeaf6;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body { font-size: var(--fs-body); line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
button { margin: 0; padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
h1, h2, h3, h4, p, dl, dd, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

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

/* --------------------------------- type --------------------------------- */
.t-display, h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.005em; line-height: 1.1; }
.label {
  font: 800 var(--fs-label)/1 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.muted { color: var(--ink-2); }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }

/* --------------------------------- icons -------------------------------- */
.ico {
  width: 1em; height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico.is-fill, .ico .fill { fill: currentColor; }
.ico.is-fill { stroke: none; }

/* -------------------------------- buttons ------------------------------- */
/* --b-face and --b-lip pick the colour; everything else is shared. */
.btn {
  --b-face: var(--green);
  --b-lip: var(--green-lip);
  --b-ink: #ffffff;
  --b-depth: 4px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: var(--r-btn);
  background: var(--b-face);
  color: var(--b-ink);
  font: 600 var(--fs-head)/1 var(--font-display);
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 var(--b-depth) 0 var(--b-lip);
  margin-bottom: var(--b-depth);
  transition: transform 70ms ease, box-shadow 70ms ease, filter 120ms ease;
  user-select: none;
}
.btn .ico { font-size: 1.1em; }
.btn:hover { filter: brightness(1.04); }
.btn:active:not(:disabled), .btn.is-down {
  transform: translateY(var(--b-depth));
  box-shadow: 0 0 0 var(--b-lip);
}
.btn:disabled { --b-face: var(--surface-2); --b-lip: var(--lip); --b-ink: var(--ink-3); filter: none; }
.btn.is-quiet { --b-face: var(--surface-2); --b-lip: var(--lip); --b-ink: var(--ink); }
.btn.is-white { --b-face: #ffffff; --b-lip: var(--lip); --b-ink: var(--ink); }
.btn.is-gold { --b-face: var(--gold); --b-lip: var(--gold-lip); --b-ink: #5b3d00; }
.btn.is-danger { --b-face: var(--coral); --b-lip: var(--coral-lip); }
.btn.is-big { min-height: calc(var(--tap) + 10px); padding: 0 28px; font-size: calc(var(--fs-head) + 4px); border-radius: 18px; --b-depth: 5px; }
.btn.is-small { min-height: 36px; padding: 0 14px; font-size: var(--fs-body); border-radius: 12px; --b-depth: 3px; }
.btn.is-wide { width: 100%; }

/* A text link that behaves like a button. */
.link {
  padding: 6px 4px;
  color: var(--green-ink);
  font: 700 var(--fs-body)/1.2 var(--font-ui);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link.is-muted { color: var(--ink-2); }

/* A round floating button: pause, zoom, back, close. */
.icon-btn {
  display: grid;
  place-items: center;
  width: var(--tap); height: var(--tap);
  flex: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  box-shadow: var(--shadow-float);
  transition: transform 70ms ease, box-shadow 70ms ease;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(23, 51, 43, 0.14), 0 4px 10px rgba(23, 51, 43, 0.16); }
.icon-btn.is-flat { box-shadow: none; background: var(--surface-2); }
.icon-btn.is-flat:active { transform: scale(0.94); box-shadow: none; }

/* --------------------------------- chips -------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font: 700 var(--fs-small)/1 var(--font-ui);
  white-space: nowrap;
}
.chip .ico { font-size: 1.1em; }
.chip.is-green { background: var(--green-soft); color: var(--green-ink); }
.chip.is-gold { background: var(--gold-soft); color: var(--gold-ink); }
.chip.is-blue { background: var(--blue-soft); color: var(--blue-ink); }
.chip.is-coral { background: var(--coral-soft); color: var(--coral-ink); }
.chip.is-grape { background: var(--grape-soft); color: var(--grape-ink); }
.chip.is-white { background: rgba(255, 255, 255, 0.94); color: var(--ink); }
.chip.is-dark { background: rgba(23, 51, 43, 0.72); color: #fff; }

/* A count that wants attention. */
.badge {
  display: inline-block;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--coral);
  color: #fff;
  font: 700 12px/22px var(--font-ui);
  text-align: center;
}

/* A coin: a small gold disc. */
.coin {
  display: inline-block;
  width: 18px; height: 18px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3b0 0 18%, #ffcf3f 19% 62%, #e9a70c 63%);
  box-shadow: 0 1.5px 0 #b97d00;
}

/* --------------------------------- panels ------------------------------- */
.panel {
  background: var(--surface);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-panel);
}
/* A tile inside a panel: a stat, a hole, a row. Pressable ones get a lip. */
.tile {
  border-radius: var(--r-tile);
  background: var(--surface-2);
}
button.tile, a.tile { box-shadow: 0 3px 0 var(--lip); transition: transform 70ms ease, box-shadow 70ms ease; }
button.tile:active:not(:disabled), a.tile:active { transform: translateY(3px); box-shadow: 0 0 0 var(--lip); }

/* A floating pill over the course or the sky: currency, wind, the hole. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 13px 0 9px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 16px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-float);
  white-space: nowrap;
}
button.pill { transition: transform 70ms ease, box-shadow 70ms ease; }
button.pill:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(23, 51, 43, 0.14), 0 4px 10px rgba(23, 51, 43, 0.16); }

/* The level: a number in a ring that fills toward the next level. */
.ring {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--tap); height: var(--tap);
  flex: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font: 700 18px/1 var(--font-display);
  box-shadow: var(--shadow-float);
}
.ring svg { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4.5; }
.ring .ring-back { stroke: var(--surface-2); }
.ring .ring-fill { stroke: var(--green); stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }
.ring > span { position: relative; }
button.ring { transition: transform 70ms ease, box-shadow 70ms ease; }
button.ring:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(23, 51, 43, 0.14), 0 4px 10px rgba(23, 51, 43, 0.16); }

/* A progress bar. */
.bar {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--green); transition: width 0.5s ease; }
.bar.is-gold > i { background: var(--gold); }
.bar.is-grape > i { background: var(--grape); }
.bar.is-big { height: 12px; border-radius: 6px; }
.bar.is-flash { animation: bar-flash 0.5s ease-out; }
@keyframes bar-flash { 0% { box-shadow: 0 0 0 0 rgba(255, 203, 61, 0.9); } 100% { box-shadow: 0 0 0 10px rgba(255, 203, 61, 0); } }

/* Segmented control: two to five choices, one on. */
.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(23, 51, 43, 0.05);
}
.seg > button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--ink-2);
  font: 600 var(--fs-body)/1 var(--font-display);
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease;
}
.seg > button small { font: 700 var(--fs-label)/1 var(--font-ui); opacity: 0.75; }
.seg > button[aria-selected="true"], .seg > button[aria-pressed="true"], .seg > button.is-selected {
  background: var(--green);
  color: #fff;
  box-shadow: 0 3px 0 var(--green-lip);
}
.seg.is-inset { background: var(--surface-2); box-shadow: none; }

/* --------------------------------- forms -------------------------------- */
.field { display: grid; gap: 6px; }
.field > label, .field-label { font: 700 var(--fs-small)/1.2 var(--font-ui); color: var(--ink-2); }
.input, .field input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: 600 var(--fs-body)/1.2 var(--font-ui);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input:focus, .field input:focus { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.hint { font-size: var(--fs-small); color: var(--ink-2); }
.form-error { padding: 8px 12px; border-radius: 12px; background: var(--coral-soft); color: var(--coral-ink); font: 700 var(--fs-small)/1.3 var(--font-ui); }
.flash { padding: 10px 14px; border-radius: 14px; background: var(--blue-soft); color: var(--blue-ink); font: 700 var(--fs-small)/1.3 var(--font-ui); }
.flash.ok { background: var(--green-soft); color: var(--green-ink); }
.flash.bad { background: var(--coral-soft); color: var(--coral-ink); }

/* -------------------------------- dialogs ------------------------------- */
/* A dimmed screen with one panel in the middle. */
.modal, .sheet-wrap {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: max(12px, var(--safe-t)) max(12px, var(--safe-r)) max(12px, var(--safe-b)) max(12px, var(--safe-l));
  background: rgba(16, 44, 36, 0.42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 20px 22px;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 0 6px 0 var(--lip), 0 24px 50px rgba(10, 40, 30, 0.3);
  animation: pop-in 0.3s cubic-bezier(.2, .9, .3, 1.2) both;
}
.modal-card > h2, .modal-card > h3 { font-size: var(--fs-title); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }

/* The controller's highlight (js/padnav.js), in this system's colours. */
body.pad-active :focus {
  outline: 4px solid var(--gold) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 8px rgba(255, 203, 61, 0.3) !important;
}

@media (prefers-reduced-motion: reduce) {
  .btn, .icon-btn, button.tile, button.pill, button.ring { transition: none; }
  .modal-card { animation: none; }
  .bar > i, .ring .ring-fill { transition: none; }
}
