/* ==========================================================================
   SPRINKLERDUDE UI KIT — STEP 4: TITLE SCREEN, PAUSE MENU, SETTINGS
   Paste after the step 3 block.
   Covers ARCHITECTURE.md section 4: #1 Title screen, #2 Name prompt,
   #6 Pause menu, #7 Settings / Controls.

   The title screen and the pause menu are ink surfaces: the game is stopped.
   Settings, Controls and the name prompt are ordinary paper panels.
   ========================================================================== */

/* 6.0 Tokens --------------------------------------------------------------- */
:root {
  --sd-title-scrim: rgba(20, 24, 27, 0.9);          /* edge of the title vignette */
  --sd-title-scrim-mid: rgba(20, 24, 27, 0.78);     /* centre: a hint of the world shows */
  --sd-title-max: 420px;
  --sd-title-max-lg: 520px;                         /* desktop: room for the one-line lockup */
  --sd-title-max-wide: 780px;                       /* two columns on a landscape phone */
  --sd-logo-max: 400px;
  --sd-logo-max-sm: 250px;
  --sd-fs-4xl: 3.25rem;                             /* 52 — "Master Shovel" on desktop */
  --sd-shadow-type: 0 3px 0 var(--sd-black);        /* hard drop under display type */
  --sd-panel-medium: 600px;
  --sd-switch-w: 52px;
  --sd-switch-h: 30px;
  --sd-switch-knob: 20px;
  --sd-input-h: 48px;
  --sd-z-title: 10;
}

/* 6.1 Title screen --------------------------------------------------------- */
.sd-title {
  --sd-edge: var(--sd-black);
  position: absolute;
  inset: 0;
  z-index: var(--sd-z-title);
  display: grid;
  place-items: center;
  overflow: auto;
  padding: calc(var(--sd-sp-4) + var(--sd-safe-t)) calc(var(--sd-sp-4) + var(--sd-safe-r))
           calc(var(--sd-sp-4) + var(--sd-safe-b)) calc(var(--sd-sp-4) + var(--sd-safe-l));
  background: radial-gradient(ellipse at center, var(--sd-title-scrim-mid), var(--sd-title-scrim));
  color: var(--sd-paper);
  font-family: var(--sd-font-body);
}
.sd-title :focus-visible,
.sd-panel--ink :focus-visible { outline-color: var(--sd-lime); }

.sd-title__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sd-sp-3);
  width: 100%;
  max-width: var(--sd-title-max);
  text-align: center;
}
.sd-title__logo {
  display: block;
  width: 100%;
  max-width: var(--sd-logo-max-sm);
  height: auto;
}
/* <h1>Quest for the <span>Master Shovel</span></h1>: a two-line lockup */
.sd-title__heading {
  margin: 0;
  font-family: var(--sd-font-display);
  font-stretch: condensed;
  font-size: var(--sd-fs-xl);
  font-style: italic;
  font-weight: 800;
  line-height: var(--sd-lh-tight);
  letter-spacing: var(--sd-track);
  text-transform: uppercase;
  text-shadow: var(--sd-shadow-type);
}
.sd-title__heading span {
  display: block;
  color: var(--sd-lime);
  font-size: var(--sd-fs-3xl);
}
.sd-title__heading::after {           /* the lime and blue stripes from the wordmark */
  content: "";
  display: block;
  width: 132px;
  height: 8px;
  margin: var(--sd-sp-2) auto 0;
  background: linear-gradient(var(--sd-lime) 0, var(--sd-lime) 50%, var(--sd-blue) 50%);
}
.sd-title__tagline {
  margin: 0;
  color: var(--sd-hud-soft);
  font-size: var(--sd-fs-sm);
  font-weight: 600;
  line-height: 1.35;
}
.sd-title__actions {
  display: flex;
  flex-direction: column;
  gap: var(--sd-sp-3);
  width: 100%;
  margin-top: var(--sd-sp-2);
  padding-bottom: 4px;                /* room for the last button's hard shadow */
}
.sd-title__actions > .sd-btn { width: 100%; }
/* With Continue showing, New Game steps back so there is one obvious button */
.sd-title__actions > .sd-btn--primary:not([hidden]) ~ .sd-btn--primary { background: var(--sd-paper); }
@media (hover: hover) {
  .sd-title__actions > .sd-btn--primary:not([hidden]) ~ .sd-btn--primary:hover { background: var(--sd-lime-tint); }
}
.sd-title__detail {                   /* the line under Continue */
  margin: calc(-1 * var(--sd-sp-1)) 0 0;
  color: var(--sd-hud-soft);
  font-size: var(--sd-fs-sm);
}
.sd-title__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sd-sp-3);
}
.sd-title__row > .sd-btn { min-width: 0; padding: 0 var(--sd-sp-2); }
.sd-title__note { width: 100%; color: var(--sd-ink); text-align: left; }   /* a kit .sd-callout */
.sd-title__fine {
  margin: 0;
  color: var(--sd-hud-soft);
  font-size: var(--sd-fs-xs);
  line-height: 1.35;
}

/* Desktop and tablets: bigger logo and lockup */
@container sd-viewport (min-width: 600px) and (min-height: 521px) {
  .sd-title__card { gap: var(--sd-sp-4); max-width: var(--sd-title-max-lg); }
  .sd-title__logo { max-width: var(--sd-logo-max); }
  .sd-title__heading { font-size: var(--sd-fs-2xl); }
  .sd-title__heading span { font-size: var(--sd-fs-4xl); white-space: nowrap; }
  .sd-title__actions { max-width: 340px; }
}

/* Phone landscape: brand on the left, buttons on the right */
@container sd-viewport (min-width: 600px) and (max-height: 520px) {
  .sd-title__card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
    grid-template-areas:
      "logo    actions"
      "heading actions"
      "tagline actions"
      "fine    actions"
      "note    note";
    align-items: center;
    justify-items: center;
    gap: var(--sd-sp-2) var(--sd-sp-5);
    max-width: var(--sd-title-max-wide);
  }
  .sd-title__logo    { grid-area: logo; }
  .sd-title__heading { grid-area: heading; }
  .sd-title__tagline { grid-area: tagline; }
  .sd-title__fine    { grid-area: fine; }
  .sd-title__note    { grid-area: note; }
  .sd-title__actions { grid-area: actions; gap: var(--sd-sp-2); margin-top: 0; }
  .sd-title__heading span { font-size: var(--sd-fs-2xl); white-space: nowrap; }
}

/* 6.2 Pause menu ----------------------------------------------------------- */
/* A kit panel with an ink body: <section class="sd-panel sd-panel--narrow sd-panel--ink"> */
.sd-panel--medium { max-width: var(--sd-panel-medium); }
.sd-panel--ink { --sd-edge: var(--sd-black); }
.sd-panel--ink .sd-panel__body {
  background: var(--sd-ink-raised);
  color: var(--sd-paper);
}
/* A stack of full-width buttons, used by the pause menu.
   .sd-menu__group holds buttons that belong together; on a short screen
   each group turns into one row so all six buttons fit without scrolling. */
.sd-menu,
.sd-menu__group {
  display: flex;
  flex-direction: column;
  gap: var(--sd-sp-3);
}
.sd-menu { padding-bottom: 4px; }
.sd-menu .sd-btn { width: 100%; }
.sd-menu__sep {                       /* sets the destructive choice apart */
  height: 0;
  margin: var(--sd-sp-1) 0;
  border: 0;
  border-top: var(--sd-bw) dashed var(--sd-hud-key-line);
}

@container sd-viewport (max-height: 520px) {
  .sd-panel--ink { max-width: var(--sd-panel-medium); }
  .sd-menu { gap: var(--sd-sp-2); }
  .sd-menu__group { flex-direction: row; gap: var(--sd-sp-2); }
  .sd-menu__group > .sd-btn { flex: 1 1 0; min-width: 0; padding: 0 var(--sd-sp-2); }
  .sd-menu__sep { margin: 0; }
}

/* 6.3 Settings: on/off rows ------------------------------------------------ */
/* <label class="sd-check"><span class="sd-check__text">…</span><input type="checkbox" class="sd-check__box"></label> */
.sd-settings { margin: 0; padding: 0; border: 0; }
.sd-check {
  display: flex;
  align-items: center;
  gap: var(--sd-sp-4);
  min-height: var(--sd-tap);
  padding: var(--sd-sp-3) 0;
  border-bottom: 1px solid var(--sd-line);
  cursor: pointer;
}
.sd-check:last-child { border-bottom: 0; }
.sd-check__text { flex: 1; min-width: 0; }
.sd-check__label { display: block; font-weight: 800; }
.sd-check__hint {
  display: block;
  color: var(--sd-ink-soft);
  font-size: var(--sd-fs-sm);
  line-height: 1.35;
}
/* The checkbox draws as a switch. On = lime with the knob on the right,
   so the state reads from position as well as color. */
.sd-check__box {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: var(--sd-switch-w);
  height: var(--sd-switch-h);
  margin: 0;
  border: var(--sd-bw) solid var(--sd-ink);
  border-radius: var(--sd-r-pill);
  background-color: var(--sd-paper-2);
  background-image: radial-gradient(circle closest-side, var(--sd-ink) 0, var(--sd-ink) 94%, transparent 100%);
  background-size: var(--sd-switch-knob) var(--sd-switch-knob);
  background-position: 3px 50%;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: background-position var(--sd-dur) ease-out, background-color var(--sd-dur) ease-out;
}
.sd-check__box:checked {
  background-color: var(--sd-lime);
  background-position: calc(100% - 3px) 50%;
}
.sd-check__box:disabled {
  border-style: dashed;
  border-color: var(--sd-ink-soft);
  background-image: radial-gradient(circle closest-side, var(--sd-ink-soft) 0, var(--sd-ink-soft) 94%, transparent 100%);
  cursor: not-allowed;
}

/* 6.4 Controls: key caps --------------------------------------------------- */
/* Use inside a kit .sd-table: <td><span class="sd-keys"><kbd class="sd-kbd">E</kbd></span></td> */
/* .sd-table--keys tightens the cells so action names fit beside the keys on a phone */
.sd-table--keys th,
.sd-table--keys td { padding-left: var(--sd-sp-3); padding-right: var(--sd-sp-3); vertical-align: middle; }
.sd-keys {
  display: inline-flex;
  align-items: center;
  gap: var(--sd-sp-1);
}
.sd-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 var(--sd-sp-2);
  border: var(--sd-bw) solid var(--sd-ink);
  border-bottom-width: 4px;
  border-radius: var(--sd-r-sm);
  background: var(--sd-paper);
  color: var(--sd-ink);
  font-family: var(--sd-font-body);
  font-size: var(--sd-fs-sm);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

/* 6.5 Name prompt: text field ---------------------------------------------- */
.sd-field {
  display: flex;
  flex-direction: column;
  gap: var(--sd-sp-2);
}
.sd-field__label { font-size: var(--sd-fs-lg); font-weight: 800; }
.sd-field__hint { color: var(--sd-ink-soft); font-size: var(--sd-fs-sm); }
.sd-input {
  width: 100%;
  min-height: var(--sd-input-h);
  padding: 0 var(--sd-sp-3);
  border: var(--sd-bw-heavy) solid var(--sd-ink);
  border-radius: var(--sd-r-md);
  background: var(--sd-paper);
  color: var(--sd-ink);
  font-family: var(--sd-font-body);
  font-size: var(--sd-fs-lg);
  font-weight: 700;
  -webkit-user-select: text;
  user-select: text;
}
.sd-input::placeholder { color: var(--sd-ink-soft); font-weight: 400; }

/* 6.6 Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .sd-check__box { transition: none; }
}
