/* css/styles.css */
:root {
  --md-sys-color-primary: #0fa3b1;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-secondary: #ff7a59;
  --md-sys-color-on-secondary: #0f172a;
  --md-sys-color-tertiary: #ffd166;
  --md-sys-color-surface: #ffffff;
  --md-sys-color-on-surface: #0f172a;
  --md-sys-color-muted: #475569;
  --md-sys-color-outline: rgba(15, 23, 42, 0.12);
  --md-sys-color-positive: #0ea5e9;
  --md-sys-color-on-positive: #ffffff;
  --app-max-width: 980px;
  --md-radius: 22px;
  --md-radius-xl: 28px;
  --elevation-1: 0 10px 28px rgba(15, 163, 177, 0.16), 0 4px 14px rgba(0, 0, 0, 0.04);
  --elevation-2: 0 16px 36px rgba(255, 122, 89, 0.18), 0 8px 24px rgba(0, 0, 0, 0.06);
  --elevation-3: 0 28px 68px rgba(14, 165, 233, 0.22), 0 16px 32px rgba(0, 0, 0, 0.08);
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Manrope', 'Baloo 2', system-ui, sans-serif;
  background:
    radial-gradient(120% 120% at 10% 10%, rgba(14, 165, 233, 0.08), transparent),
    radial-gradient(140% 140% at 90% 20%, rgba(255, 122, 89, 0.12), transparent),
    radial-gradient(160% 160% at 50% 90%, rgba(42, 193, 132, 0.08), transparent),
    #f8fafc;
  color: var(--md-sys-color-on-surface);
}

h1, h2, h3 {
  font-family: 'Baloo 2', 'Manrope', sans-serif;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  letter-spacing: 0.1px;
}

#app {
  max-width: var(--app-max-width);
  margin: 12px auto 32px;
  padding: 16px;
}


.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(120deg, rgba(15, 163, 177, 0.82), rgba(14, 165, 233, 0.88), rgba(255, 122, 89, 0.85));
  color: #ffffff;
  box-shadow: var(--elevation-1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  box-sizing: border-box;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 1.6rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-family: 'Baloo 2', 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
}

.brand-subtitle {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
}

.menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  font-weight: 800;
  letter-spacing: 0.25px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 160ms ease, background 140ms ease;
}

.menu-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.menu-button:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

md-filled-button,
md-filled-tonal-button,
md-elevated-button,
md-outlined-button {
  --md-sys-color-primary: var(--md-sys-color-primary);
  --md-sys-color-on-primary: var(--md-sys-color-on-primary);
  min-height: 56px;
  min-width: 120px;
  border-radius: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 160ms ease;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

.icon-only {
  min-width: 56px;
  max-width: 56px;
  min-height: 56px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

md-filled-button:hover,
md-filled-tonal-button:hover,
md-elevated-button:hover,
md-outlined-button:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.25);
}

md-filled-button:active,
md-filled-tonal-button:active,
md-elevated-button:active,
md-outlined-button:active {
  transform: translateY(1px) scale(0.99);
}

md-assist-chip,
md-suggestion-chip,
md-input-chip,
md-filter-chip {
  --md-sys-color-primary: var(--md-sys-color-primary);
  border-radius: 12px;
}

md-filled-button.positive,
md-filled-tonal-button.positive,
md-elevated-button.positive {
  --md-sys-color-primary: var(--md-sys-color-positive);
  --md-sys-color-on-primary: var(--md-sys-color-on-positive);
  background: linear-gradient(135deg, #0ea5e9 0%, #0fa3b1 100%);
  color: var(--md-sys-color-on-positive);
  box-shadow: 0 14px 32px rgba(14, 165, 233, 0.32);
}

md-filled-button.positive svg path,
md-filled-tonal-button.positive svg path,
md-elevated-button.positive svg path {
  fill: var(--md-sys-color-on-positive);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(14, 163, 177, 0.16), rgba(255, 122, 89, 0.12)), #ffffff;
  box-shadow: var(--elevation-2);
  border: 1px solid rgba(255, 255, 255, 0.7);
  margin-bottom: 16px;
}

.hero::after {
  content: '';
  position: absolute;
  width: 320px;
  height: 320px;
  right: -120px;
  top: -140px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.18), transparent 60%);
  filter: blur(10px);
}

.hero-kicker {
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  color: var(--md-sys-color-secondary);
  font-size: 0.9rem;
}

.hero-title {
  margin: 6px 0 4px;
  font-size: 1.8rem;
  color: #0b2745;
}

.hero-subtitle {
  margin: 0;
  color: var(--md-sys-color-muted);
  font-weight: 600;
}

.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 14px 0 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  box-shadow: var(--elevation-1);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.filters label {
  font-size: 0.95rem;
  color: var(--md-sys-color-muted);
  font-weight: 700;
}

.filters input[type="number"] {
  width: 76px;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid var(--md-sys-color-outline);
  font-size: 1rem;
  background: #ffffff;
}

.filters input[type="number"]:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 4px rgba(14, 163, 177, 0.18);
}

.sort-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  box-shadow: var(--elevation-1);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.sort-row label {
  font-size: 0.95rem;
  color: var(--md-sys-color-muted);
  font-weight: 700;
}

.sort-row select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--md-sys-color-outline);
  font-size: 0.95rem;
  font-weight: 700;
  background: #ffffff;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.sort-row select:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 4px rgba(14, 163, 177, 0.18);
}

.story-list {
  display: grid;
  gap: 12px;
}

.story-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  background: #ffffff;
  border-radius: var(--md-radius);
  box-shadow: var(--elevation-1);
  border: 1px solid rgba(15, 23, 42, 0.06);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.story-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(14, 163, 177, 0.08), rgba(255, 122, 89, 0.08));
  opacity: 0;
  transition: opacity 160ms ease;
}

.story-card:hover::before,
.story-card:focus-within::before {
  opacity: 1;
}

.story-card:hover,
.story-card:focus-within {
  transform: translateY(-6px);
  box-shadow: var(--elevation-3);
}

.story-card h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.story-card p {
  margin: 0;
  color: var(--md-sys-color-muted);
  font-size: 0.98rem;
  line-height: 1.4;
}

.story-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  color: var(--md-sys-color-muted);
  font-weight: 700;
}

.word-prompt {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.word-prompt label {
  font-size: 1.2rem;
  font-weight: 700;
  color: #0b2745;
}

.prompt-hint {
  margin-top: 4px;
  display: block;
  font-size: 0.95rem;
  color: var(--md-sys-color-muted);
  font-weight: 700;
}

.word-input {
  font-size: 1.3rem;
  padding: 18px 16px;
  border-radius: 18px;
  border: 2px solid var(--md-sys-color-outline);
  transition: all 220ms ease;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.word-input:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 4px rgba(14, 163, 177, 0.18), 0 18px 38px rgba(14, 163, 177, 0.22);
  transform: translateY(-1px);
}

.suggestions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.progress-row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  margin: 8px 0;
}

.progress-label {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0b2745;
  min-width: 140px;
  white-space: nowrap;
}

md-linear-progress {
  --md-linear-progress-active-indicator-color: linear-gradient(90deg, #0fa3b1, #0ea5e9, #ff7a59);
  --md-linear-progress-track-color: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  height: 14px;
}

.action-row {
  position: sticky;
  bottom: 8px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  background: transparent;
  backdrop-filter: none;
  padding: 6px 0;
  z-index: 20;
}

.action-row md-filled-tonal-button,
.action-row md-filled-button,
.action-row md-elevated-button,
.action-row md-outlined-button {
  flex: 1;
}

.bottom-sheet {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  border-radius: 18px;
  box-shadow: var(--elevation-2);
  padding: 14px;
  z-index: 50;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.bottom-sheet .word-input {
  width: 100%;
  box-sizing: border-box;
}

.story-final {
  padding: 28px;
  border-radius: var(--md-radius-xl);
  background: linear-gradient(135deg, #ffffff, #f8fbff);
  box-shadow: var(--elevation-3);
  border: 1px solid rgba(15, 23, 42, 0.05);
  position: relative;
  font-size: 1.18rem;
  line-height: 1.9;
  color: #0b2745;
}

.story-final::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: var(--md-radius-xl);
  background: linear-gradient(130deg, rgba(14, 163, 177, 0.25), rgba(255, 122, 89, 0.2), rgba(42, 193, 132, 0.22));
  z-index: -1;
  filter: blur(16px);
}

.marked-word {
  font-weight: 800;
  color: var(--md-sys-color-primary);
  background: transparent;
  padding: 4px 8px;
  border-radius: 10px;
  display: inline-block;
  margin: 0 4px;
  transition: transform 160ms ease, box-shadow 160ms ease;
  border: 2px solid rgba(15,23,42,0.06);
}

.marked-word:nth-child(even) {
  color: var(--md-sys-color-secondary);
  border-color: rgba(14,163,177,0.12);
}

.marked-word:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15,23,42,0.08);
}

.final-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.final-actions md-outlined-button,
.final-actions md-filled-tonal-button,
.final-actions md-elevated-button {
  flex: 1;
}

.fade-in { animation: fadeIn 260ms ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.slide-up { animation: slideUp 240ms cubic-bezier(0, 0, 0.2, 1) both; }
@keyframes slideUp { from { transform: translateY(18px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.bounce-in { animation: bounceIn 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55) both; }
@keyframes bounceIn {
  0% { transform: scale(0.9) translateY(8px); opacity: 0; }
  50% { transform: scale(1.03) translateY(-4px); opacity: 1; }
  100% { transform: scale(1) translateY(0); }
}

.wiggle { animation: wiggle 380ms ease-in-out; }
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-4deg); }
  75% { transform: rotate(4deg); }
}

.pop { animation: pop 280ms cubic-bezier(0.68, -0.55, 0.265, 1.55); }
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.celebrate { animation: celebrate 560ms ease-out; }
@keyframes celebrate {
  0% { transform: scale(0.96); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

button, input { min-height: 48px; }

@media (max-width: 720px) {
  #app { padding: 10px; }
  .story-card { flex-direction: column; align-items: flex-start; }
  .story-meta { flex-wrap: wrap; }
  .hero { padding: 18px; }
  
  /* Entry page mobile optimizations */
  .progress-label { min-width: 100px; font-size: 0.9rem; }
  .word-prompt { gap: 12px; margin-top: 12px; }
  .word-prompt label { font-size: 1.1rem; }
  .word-input { font-size: 1.2rem; padding: 16px 14px; }
  .suggestions-row { gap: 6px; }
  .bottom-sheet { left: 8px; right: 8px; bottom: 8px; padding: 12px; }
}
