/* style.css — shared design system for Dailydle */

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

:root {
  --bg:           #121213;
  --surface:      #1a1a1b;
  --border:       #3a3a3c;
  --border-focus: #565758;
  --text:         #ffffff;
  --text-muted:   #818384;
  --correct:      #538d4e;
  --present:      #b59f3b;
  --absent:       #3a3a3c;
  --key-bg:       #818384;
  --key-text:     #ffffff;
  --radius:       4px;
  --tile-size:    62px;
  --gap:          5px;
  --font:         'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.site-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.hub-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: var(--radius);
  transition: color 0.15s, border-color 0.15s;
}
.hub-link:hover { color: var(--text); border-color: var(--text-muted); }

.header-score {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Game container ──────────────────────────────────────────────────────── */

.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 500px;
  margin: 0 auto;
  padding: 12px 16px 24px;
  gap: 12px;
}

/* ── Image section ───────────────────────────────────────────────────────── */

.image-section {
  width: 100%;
  max-width: 360px;
  position: relative;
}

.puzzle-image {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: var(--surface);
}

.image-skeleton {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 8px;
  background: var(--surface);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.image-caption {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

/* ── Hints ───────────────────────────────────────────────────────────────── */

.hints-section {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hint-buttons {
  display: flex;
  gap: 6px;
}

.hint-btn {
  flex: 1;
  padding: 7px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.hint-btn:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

.hint-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.hint-btn.revealed {
  background: var(--present);
  border-color: var(--present);
  color: var(--text);
  opacity: 1;
  cursor: default;
}

.hint-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.45;
  display: none;
  animation: fadeIn 0.25s ease;
}

.hint-text.visible { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Tile grid ───────────────────────────────────────────────────────────── */

.tile-grid {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.tile-row {
  display: flex;
  gap: var(--gap);
}

.tile-row.shake { animation: shake 0.5s ease; }

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid var(--border);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  user-select: none;
  position: relative;
  transition: border-color 0.05s;
  transform-style: preserve-3d;
}

.tile[data-letter] {
  border-color: var(--border-focus);
  animation: pop 0.1s ease;
}

.tile.correct { background: var(--correct); border-color: var(--correct); color: #fff; }
.tile.present { background: var(--present); border-color: var(--present); color: #fff; }
.tile.absent  { background: var(--absent);  border-color: #585858;        color: #fff; }

.tile.flip {
  animation: flip 0.5s ease forwards;
}

@keyframes flip {
  0%   { transform: rotateX(0deg);   }
  49%  { transform: rotateX(-90deg); }
  50%  { transform: rotateX(-90deg); }
  100% { transform: rotateX(0deg);   }
}

@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-6px); }
  30%, 70%      { transform: translateX(6px); }
}

@keyframes bounce {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-18px); }
  60%  { transform: translateY(-10px); }
  80%  { transform: translateY(-5px); }
  100% { transform: translateY(0); }
}

/* ── Toast notification ──────────────────────────────────────────────────── */

.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1000;
  white-space: nowrap;
}

.toast.show { opacity: 1; }

/* ── Keyboard ────────────────────────────────────────────────────────────── */

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  max-width: 360px;
  touch-action: manipulation;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.key {
  height: 56px;
  min-width: 42px;
  flex: 1;
  max-width: 50px;
  background: var(--key-bg);
  border: none;
  border-radius: 4px;
  color: var(--key-text);
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

.key:active { filter: brightness(0.85); }

.key.wide {
  min-width: 60px;
  max-width: 80px;
  font-size: 0.75rem;
}

.key.correct { background: var(--correct); }
.key.present { background: var(--present); }
.key.absent  { background: var(--absent);  }

/* ── Modal ───────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  width: 90%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transform: translateY(12px);
  transition: transform 0.3s;
  text-align: center;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modal-answer {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.modal-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: -8px;
}

.score-breakdown {
  width: 100%;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.score-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}
.score-line span:first-child { color: var(--text-muted); }
.score-line span:last-child  { font-weight: 700; }
.score-line.total span       { color: var(--text); font-size: 1rem; }

/* Per-guess breakdown rows */
#score-guess-rows {
  width: 100%;
  padding-bottom: 6px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
}

.guess-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 2px 0;
}
.guess-row span:first-child { color: var(--text-muted); }
.guess-row span:last-child  { font-weight: 600; font-variant-numeric: tabular-nums; }
.guess-row.best-guess span  { color: var(--correct); }
.guess-off { font-size: 0.68rem; opacity: 0.7; }

.score-counter {
  font-size: 3rem;
  font-weight: 700;
  color: var(--correct);
  letter-spacing: 0.02em;
}

.share-grid {
  font-size: 1.4rem;
  line-height: 1.6;
  letter-spacing: 2px;
  white-space: pre;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: filter 0.15s;
}
.btn:active { filter: brightness(0.85); }
.btn-share  { background: var(--correct); color: #fff; }
.btn-muted  { background: var(--border); color: var(--text-muted); }

.countdown-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.countdown-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.countdown-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Streak badge ────────────────────────────────────────────────────────── */

.streak-badge {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.streak-badge.visible { display: flex; }
.streak-badge .snum { color: var(--text); font-size: 1rem; }

.modal-streak {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  padding: 6px 14px;
  background: rgba(255,160,0,0.12);
  border: 1px solid rgba(255,160,0,0.3);
  border-radius: 20px;
}
.modal-streak.visible { display: flex; }
.modal-streak .streak-fire { font-size: 1.2rem; }

/* ── Scoring explainer dropdown (modal) ─────────────────────────────────── */

.scoring-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s;
}
.scoring-toggle:hover { border-color: var(--text-muted); color: var(--text); }

.scoring-arrow {
  font-size: 0.55rem;
  transition: transform 0.2s;
}
.scoring-toggle.open .scoring-arrow { transform: rotate(180deg); }

.scoring-panel {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: -8px;
}
.scoring-panel.open { display: flex; }

.scoring-block { display: flex; flex-direction: column; gap: 4px; }

.scoring-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.scoring-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}
.scoring-table td { padding: 2px 0; color: var(--text-muted); }
.scoring-table td:last-child { text-align: right; color: var(--text); font-weight: 600; }
.scoring-table tr + tr td { border-top: 1px solid rgba(255,255,255,0.05); }

.scoring-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.scoring-note strong { color: var(--text); }

/* ── Zoom overlay ─────────────────────────────────────────────────────────── */

.zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.96);
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.zoom-overlay.open { display: flex; }
.zoom-overlay img {
  max-width: 96vw;
  max-height: 96vh;
  object-fit: contain;
  border-radius: 4px;
  pointer-events: none;
}

.zoom-hint {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: -4px;
}

/* ── Score bottom sheet ──────────────────────────────────────────────────── */

.score-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 290;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.score-backdrop.visible { opacity: 1; pointer-events: all; }

.score-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: min(480px, 100vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  z-index: 300;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
}
.score-sheet.peeking { transform: translateX(-50%) translateY(calc(100% - 54px)); }
.score-sheet.open    { transform: translateX(-50%) translateY(0); }

.score-sheet-handle {
  height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.score-sheet-pill {
  width: 40px;
  height: 4px;
  background: var(--border-focus);
  border-radius: 2px;
}
.score-sheet-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.score-sheet-body {
  padding: 0 24px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-height: 75vh;
  overflow-y: auto;
  text-align: center;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 380px) {
  :root { --tile-size: 54px; }
  .key  { height: 50px; min-width: 36px; font-size: 0.8rem; }
  .key.wide { min-width: 52px; font-size: 0.7rem; }

  /* Tighter header for narrow phones */
  .site-header { padding: 0 10px; }
  .hub-link     { padding: 4px 7px; font-size: 0.72rem; }

  /* Slider games */
  .game-wrapper { padding: 8px 12px 80px; }
  .slider-current { font-size: 1.5rem; }
  .hint-btn { font-size: 0.68rem; padding: 6px 0; }
}

@media (max-width: 480px) {
  /* Ensure bottom content never hides behind the score pull-up tab */
  .game-wrapper { padding-bottom: 70px; }

  /* Shrink hub link to arrow-only so it doesn't crowd the centered title */
  .hub-link { font-size: 0; padding: 6px 10px; }
  .hub-link::before { content: '←'; font-size: 0.82rem; }
}

@media (min-height: 750px) {
  :root { --tile-size: 66px; }
}

/* ── Score tier colors ───────────────────────────────────────────────────── */

.score-tier-gold   { color: #FFD700 !important; }
.score-tier-silver { color: #C0C0C0 !important; }
.score-tier-bronze { color: #CD7F32 !important; }
.score-tier-zero   { color: #555 !important; }

/* ── Hint button locked / unlock animation ───────────────────────────────── */

.hint-btn[data-locked="true"] { opacity: 0.45; }

@keyframes hint-unlock {
  0%   { transform: scale(1.1) translateY(-3px); }
  55%  { transform: scale(0.96); }
  100% { transform: scale(1) translateY(0); }
}
.hint-btn.unlocked { animation: hint-unlock 0.38s ease; }
