/**
 * assets/styles.css
 * Version: 2.10
 * Created: 26/12 12:29
 * Updated: 27/12 12:34 - Tighter panel padding, ELDROW padding from edge
 * 
 * Eldrow stylesheet
 * - Core layout and theming
 * - Board and tile styling
 * - Keyboard styling
 * - Modal styling
 * - Animations (toast, jiggle)
 */

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  --bg: #0b0e14;
  --ink: #e6e7ea;
  --tile-border: #2a3040;
  --good: #22c67e;
  --warn: #e8a035;
  --miss: #636b78;
  --key: #6b7585;
  --key-dark: #4a5060;
  --key-ink: #fff;
  --panels-h: 60vh;
  --gutter-w: 34px;
  --between-panels: 3px;
  --panel-pad-x: 10px;
  --panel-pad-y: 6px;
  --tile-gap: 1px;
  --tile-size-clues: 34px;
  --tile-size-guesses: 34px;
  --key-height: 48px;
  --key-gap: 6px;
  --dock-pad: 6px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 ui-sans-serif, -apple-system, system-ui, Segoe UI, Roboto, Helvetica, Arial;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================
   CORNER BUTTONS
   ============================================================ */
.corner {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top, 0px));
  width: 34px;
  height: 34px;
  z-index: 10;
  display: grid;
  place-items: center;
  border: 1px solid var(--tile-border);
  border-radius: 8px;
  color: #e9eaef;
  background: #0a0e15;
  user-select: none;
  touch-action: manipulation;
  font-weight: 900;
  font-size: 18px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .35);
}

.corner.share { left: 0; width: var(--gutter-w); }
.corner.help { right: 0; width: var(--gutter-w); }
.corner.disabled { opacity: .45; pointer-events: none; }

/* ============================================================
   MENU (dropdown)
   ============================================================ */
.menu {
  position: fixed;
  top: 40px;
  left: 8px;
  z-index: 20;
  display: none;
  flex-direction: column;
  gap: 6px;
  background: #111620;
  border: 1px solid var(--tile-border);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
}

.menu.show { display: flex; }

.menu button {
  border: 1px solid var(--tile-border);
  background: #161c28;
  color: #e6e7ea;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.menu button.active { outline: 2px solid #5ba4d9; }

/* ============================================================
   WORK AREA / LAYOUT
   ============================================================ */
.wrap {
  height: var(--panels-h);
  padding: 0;
  position: relative;
  display: grid;
  grid-template-columns: var(--gutter-w) 1fr var(--gutter-w);
  column-gap: 4px;
}

.vmode {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 16px;
  letter-spacing: .1em;
  color: #c7c7cc;
  opacity: .95;
}

.gutter-left {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: flex-end;
  padding: 10px 2px 10px 0;
  width: var(--gutter-w);
}

.gutter-left .glabel {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 9px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #c7c7cc;
  opacity: .9;
  text-align: center;
}

.gutter-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  user-select: none;
  width: var(--gutter-w);
  padding-right: 4px;
}

.gutter-right .letter {
  font-weight: 800;
  font-size: 20px;
  color: #dfe1e6;
  line-height: 1;
}

.col {
  display: flex;
  flex-direction: column;
  gap: var(--between-panels);
  height: 99%;
}

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  background: #111620;
  border: 1px solid var(--tile-border);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  min-height: 0;
  padding: var(--panel-pad-y) 2px; /* minimal left/right padding */
  box-shadow: 0 8px 24px rgba(0, 0, 0, .24);
  display: flex;
}

#clues { height: calc(var(--panels-h) * 0.40 - var(--between-panels)); }
#guesses { height: calc(var(--panels-h) * 0.60); }

.vlabel {
  display: none; /* Labels now in gutter-left */
}

.content {
  margin: auto;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* ============================================================
   BOARDS
   ============================================================ */
.board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--tile-gap);
}

/* ============================================================
   CLUES ROWS
   ============================================================ */
.row.clues {
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size-clues));
  gap: var(--tile-gap);
  height: var(--tile-size-clues);
  opacity: .84;
  filter: saturate(.98) contrast(1.04);
  transition: opacity .15s;
}

.row.clues.focus { opacity: 1; }

#boardClues .tile {
  border-width: 2px;
  width: var(--tile-size-clues);
  height: var(--tile-size-clues);
  font-size: calc(var(--tile-size-clues) * 0.54);
  line-height: 1;
}

#boardClues .row.clues.current {
  outline: 2px solid #ffffff;
  outline-offset: -2px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .25) inset;
}

/* ============================================================
   GUESSES ROWS
   ============================================================ */
.row.guesses {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size-guesses));
  gap: var(--tile-gap);
  height: var(--tile-size-guesses);
}

#boardGuesses .tile {
  width: var(--tile-size-guesses);
  height: var(--tile-size-guesses);
  font-size: calc(var(--tile-size-guesses) * 0.54);
  line-height: 1;
}

/* Guesses: vertical-only scroll; locked until Super row >= 7 */
#boardGuesses {
  max-height: 100%;
  overflow: hidden;
  overflow-x: hidden;
  padding-right: 2px;
  overscroll-behavior: contain;
  touch-action: none;
}

#boardGuesses.scroll-unlocked {
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
}

.row.guesses.active::after {
  content: attr(data-label);
  position: absolute;
  right: -26px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #1a2030;
  color: #e6e7ea;
  font-weight: 800;
  border: 1px solid var(--tile-border);
}

/* Faded rows - previous guesses (readable but muted) */
.row.guesses.faded {
  opacity: 0.5;
}

.row.guesses.faded .tile {
  border-color: #1e2535;
  background: #141a25;
  color: #888;
}

/* ============================================================
   TILES
   ============================================================ */
.tile {
  border: 2px solid var(--tile-border);
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  background: #0b0e14;
  user-select: none;
}

.tile.g { background: var(--good); border-color: var(--good); }
.tile.y { background: var(--warn); border-color: var(--warn); }
.tile.b { background: var(--miss); border-color: var(--miss); }

.row.active .tile { border-color: #5ba4d9; }

/* ============================================================
   KEYBOARD
   ============================================================ */
.dock {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: var(--dock-pad) calc(10px + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
  background: linear-gradient(0deg, rgba(0, 0, 0, .35), transparent 30%), var(--bg);
  border-top: 1px solid var(--tile-border);
}

/* Android: reduce top padding inside guesses panel */
body.platform-android #guesses .content {
  align-items: flex-start;
  margin-top: 2px;
}

.keyboard {
  display: flex;
  flex-direction: column;
  gap: var(--key-gap);
  width: 100%;
}

.krow {
  display: flex;
  justify-content: space-between;
  gap: var(--key-gap);
}

.key {
  flex: 1;
  min-width: 0;
  height: var(--key-height);
  border-radius: 6px;
  background: #6b7585;
  color: #fff;
  font-weight: 700;
  border: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  text-transform: uppercase;
  font-size: 16px;
  user-select: none;
  touch-action: manipulation;
}

.key.wide {
  flex: 2;
  background: #4a5060;
  font-size: 12px;
}

.key svg {
  width: 22px;
  height: 22px;
}

/* Keyboard colour states */
.key.g { background: var(--good) !important; border-color: var(--good) !important; color: #fff; }
.key.y { background: var(--warn) !important; border-color: var(--warn) !important; color: #000; }
.key.b { background: var(--key-dark) !important; border-color: var(--key-dark) !important; color: #fff; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: #111;
  padding: 8px 12px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 14px;
  z-index: 10000;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  opacity: 0;
  transition: opacity .15s;
}

.toast.show { opacity: 1; }

/* ============================================================
   JIGGLE ANIMATION
   ============================================================ */
.row.guesses.jiggle {
  animation: jiggle .3s ease-in-out;
}

@keyframes jiggle {
  0% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

/* ============================================================
   MODALS
   ============================================================ */
.help-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: none;
  z-index: 10001;
}

.help-wrap {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 10002;
}

.help-card {
  width: min(720px, 92vw);
  max-height: 85vh;
  overflow: auto;
  background: #111620;
  color: #e6e7ea;
  border: 1px solid #1e2535;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
  padding: 18px 18px 14px;
}

.help-card h2 { margin: 0 0 6px; font-size: 20px; }
.help-card p { margin: 6px 0 10px; color: #c9cbd1; }

/* Stage completion cards */
.help-card.stage-card {
  width: min(340px, 85vw);
  text-align: center;
  padding: 24px 28px 20px;
}

.help-card.stage-card h2 {
  font-size: 22px;
  margin-bottom: 12px;
}

.help-card.stage-card .stage-stat {
  font-size: 32px;
  font-weight: 800;
  color: #22c67e;
  margin: 16px 0;
}

.help-card.stage-card .stage-sub {
  font-size: 14px;
  color: #888;
}

.help-card.stage-card .help-actions {
  justify-content: center;
  margin-top: 16px;
}

.help-card.stage-card .btn {
  padding: 12px 24px;
  font-size: 16px;
}

.help-card .grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 760px) {
  .help-card .grid { grid-template-columns: 1fr 1fr; }
}

.help-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.btn-primary { background: #22c67e; color: #06210b; }
.btn-ghost { background: #1a2030; color: #e6e7ea; }

/* ============================================================
   HELP MODAL (compact)
   ============================================================ */
.help-card.help-compact {
  width: min(560px, 80vw);
  max-height: 85vh;
  overflow: auto;
  background: #111620;
  color: #e6e7ea;
  border: 1px solid #1e2535;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
  padding: 12px 14px 12px;
  font-size: 14px;
  line-height: 1.35;
}

.help-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
  margin-bottom: 8px;
  border-bottom: 1px solid #1e2535;
}

.help-head h2 { margin: 0; font-size: 16px; font-weight: 800; }
.help-head .tm { font-size: 70%; vertical-align: text-top; margin-left: 2px; opacity: .9; }

.help-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-head .x {
  border: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #1a2030;
  color: #e6e7ea;
  font-size: 18px;
  font-weight: 800;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.help-head .link {
  border: 0;
  background: none;
  color: #5ba4d9;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.help-head .link:hover { background: #1a2030; }

/* List + legend */
.help-list {
  list-style: disc;
  padding-left: 18px;
  margin: 0 0 10px 0;
}

.help-list li { margin: 6px 0; }

.help-list .legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 10px;
  font-weight: 600;
}

.help-card .tile {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 2px solid transparent;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}

.help-card .tile.g { background: #22c67e; border-color: #22c67e; }
.help-card .tile.y { background: #e8a035; border-color: #e8a035; color: #000; }
.help-card .tile.b { background: #636b78; border-color: #636b78; }

/* Disclaimer */
.help-disclaimer {
  margin: 6px 0 2px;
  font-size: 12px;
  color: #b7bac2;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 370px) {
  .help-card.help-compact { width: 92vw; }
  .help-head h2 { font-size: 15px; }
  .help-list { padding-left: 16px; }
}
