/*
 * GameKit — shared base for the 7Sage games.
 *
 *   <link rel="stylesheet" href="_shared/kit.css" />
 *
 * Brings in the app's fonts and its colour variables, then sets a reset
 * and base text. A game writes its own layout and its own look on top.
 *
 * Colours come from colors.gen.css, the same Figma tokens the app uses,
 * so --color-content-base or --color-surface-base match the rest of
 * 7Sage. Both files are written by `mix parse_figma_colors`.
*/

@import url("../../fonts/lexend.css");
@import url("../../fonts/fraunces.css");
@import url("./colors.gen.css");

:root {
  --font-sans: "Lexend", ui-sans-serif, system-ui, sans-serif;
  --font-serif: "Fraunces", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
}

/*
 * The game owns the whole iframe. The background stays transparent so
 * the host page shows through and the game sits on it.
*/
html,
body {
  margin: 0;
  padding: 0;
  background: transparent;
}

/* A double tap is two taps, never a zoom. */
html {
  touch-action: manipulation;
}

body {
  font-family: var(--font-sans);
  color: var(--color-content-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

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

h1,
h2,
h3 {
  font-family: var(--font-serif);
  font-weight: 600;
}

a {
  color: var(--color-content-focus);
}

strong {
  font-weight: 600;
}

/*
 * Keyboard focus stays visible everywhere, a game should restyle the
 * ring rather than removing it.
*/
:focus-visible {
  outline: 2px solid var(--color-content-focus);
  outline-offset: 2px;
}

/*
 * The kit's sheets *
 *
 * A game says what its sheets look like once, with a small palette on :root,
 * and the kit does the rest (scrim, blur, shadow, spacing).
 *
 *   :root {
 *     --gk-card: var(--card);      background of a sheet
 *     --gk-ink: var(--ink);        its text
 *     --gk-muted: var(--muted);    secondary text
 *     --gk-line: var(--line);      its border
 *     --gk-accent: var(--purple);  the primary button
 *     --gk-accent-ink: #fff;       text on the primary button
 *     --gk-radius: 6px;            corner radius of the sheet
 *     --gk-serif: var(--serif);    the title font
 *     --gk-menu-ink: #cfc4a8;      the menu buttons, when they sit on the scene
 *     --gk-menu-line: #cfc4a8;     a border around each, none by default
 *   }
 *
 * Declare them on :root: the kit mounts its sheets on <body>, so a palette
 * scoped to the game's own root element is not visible to them.
*/
.gk-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background: rgb(52 64 84 / 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.gk-sheet {
  font-family: var(--font-sans, inherit);
  font-size: 16px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  margin: auto;
  padding: 22px 24px;
  border: 1px solid var(--gk-line, var(--color-border-surface, #d9d4cc));
  border-radius: var(--gk-radius, 14px);
  background: var(--gk-card, var(--color-surface-base, #fff));
  color: var(--gk-ink, var(--color-content-base, #222));
  text-align: left;
}

.gk-sheet:focus {
  outline: none;
}

.gk-sheet-title {
  margin: 0;
  font-family: var(--gk-serif, var(--font-serif, Georgia, serif));
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

.gk-sheet-body {
  min-height: 0;
  margin: 0 -24px;
  padding: 0 24px;
  overflow-y: auto;
}

.gk-sheet p {
  margin: 12px 0 0;
  font-size: 15px;
}

.gk-section {
  margin-top: 18px;
}

.gk-sheet .gk-note {
  margin-top: 18px;
  font-size: 13px;
  color: var(--gk-muted, var(--color-content-secondary, #667085));
}

.gk-section-divided {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, currentColor 14%, transparent);
}

.gk-subtitle {
  margin: 0 0 8px;
  font-family: var(--gk-serif, var(--font-serif, Georgia, serif));
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.gk-sheet .gk-label {
  margin: 0 0 8px;
  font-size: 15px;
}

.gk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 15px;
}

.gk-hint {
  display: block;
  font-size: 13px;
  color: var(--gk-muted, var(--color-content-secondary, #667085));
}

.gk-choices {
  display: flex;
  gap: 8px;
}

.gk-choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.gk-choice {
  font: inherit;
  font-size: 14px;
  flex: 1;
  padding: 10px 8px;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: max(4px, calc(var(--gk-radius, 14px) - 6px));
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.gk-choice[aria-pressed="true"] {
  border-color: transparent;
  background: var(--gk-accent, var(--color-button-primary-default, #1f6f9c));
  color: var(--gk-accent-ink, var(--color-content-invert, #fff));
}

.gk-switch {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 22%, transparent);
  cursor: pointer;
}

.gk-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gk-card, var(--color-surface-base, #fff));
  transition: transform 0.15s;
}

.gk-switch[aria-checked="true"] {
  background: var(--gk-accent, var(--color-button-primary-default, #1f6f9c));
}

.gk-switch[aria-checked="true"]::after {
  transform: translateX(18px);
}

.gk-keys {
  display: inline-flex;
  flex: none;
  gap: 4px;
  white-space: nowrap;
}

.gk-key {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  padding: 2px 8px;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: 6px;
}

.gk-key-group {
  display: inline-flex;
  gap: 2px;
}

.gk-or {
  align-self: center;
  font-size: 13px;
  color: var(--gk-muted, var(--color-content-secondary, #667085));
}

.gk-key .gk-icon {
  width: 12px;
  height: 12px;
}

.gk-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.gk-button {
  font: inherit;
  font-weight: 600;
  width: 100%;
  padding: 13px 16px;
  border-radius: max(4px, calc(var(--gk-radius, 14px) - 4px));
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.gk-button:hover {
  background: rgba(0, 0, 0, 0.06);
}

.gk-button-primary,
.gk-button-primary:hover {
  background: var(--gk-accent, var(--color-button-primary-default, #1f6f9c));
  color: var(--gk-accent-ink, var(--color-content-invert, #fff));
}

.gk-button-primary:hover {
  filter: brightness(1.08);
}

/*
 * The menu: how to play and settings, as one small group of icon buttons the
 * game places where it fits. The icons are files drawn through a mask, so
 * they take the button's colour.
*/
.gk-menu {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#gk-menu .gk-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--gk-menu-line, transparent);
  border-radius: max(3px, calc(var(--gk-radius, 14px) - 8px));
  background: transparent;
  box-shadow: none;
  color: var(--gk-menu-ink, var(--color-content-secondary, #667085));
  opacity: 0.85;
  cursor: pointer;
}

#gk-menu .gk-menu-button:hover {
  background: transparent;
  opacity: 1;
}

.gk-icon {
  flex: none;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}

.gk-icon-sliders {
  -webkit-mask-image: url("./icons/sliders.svg");
  mask-image: url("./icons/sliders.svg");
}

.gk-icon-book {
  -webkit-mask-image: url("./icons/book-open.svg");
  mask-image: url("./icons/book-open.svg");
}

.gk-icon-volume {
  -webkit-mask-image: url("./icons/volume.svg");
  mask-image: url("./icons/volume.svg");
}

.gk-icon-volume-off {
  -webkit-mask-image: url("./icons/volume-off.svg");
  mask-image: url("./icons/volume-off.svg");
}

.gk-icon-arrow-up {
  -webkit-mask-image: url("./icons/arrow-up.svg");
  mask-image: url("./icons/arrow-up.svg");
}

.gk-icon-arrow-down {
  -webkit-mask-image: url("./icons/arrow-down.svg");
  mask-image: url("./icons/arrow-down.svg");
}

.gk-icon-arrow-left {
  -webkit-mask-image: url("./icons/arrow-left.svg");
  mask-image: url("./icons/arrow-left.svg");
}

.gk-icon-arrow-right {
  -webkit-mask-image: url("./icons/arrow-right.svg");
  mask-image: url("./icons/arrow-right.svg");
}
