/* Verse Forge — Poetic Meter & Scansion Studio */

:root {
  --bg: #0f0e17;
  --bg-card: #1a1825;
  --bg-card-alt: #211e30;
  --bg-input: #161522;
  --border: #2d2a3d;
  --border-focus: #6ee7b7;
  --text: #e8e6f0;
  --text-dim: #9896a8;
  --text-muted: #6b6880;
  --accent: #f2b705;
  --accent-dim: #c4960a;
  --stress: #e84a5f;
  --unstressed: #6ee7b7;
  --secondary: #6b8aff;
  --success: #6ee7b7;
  --coral: #f07052;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Skip Nav ── */
.skip-nav {
  position: absolute;
  top: -100px;
  left: 16px;
  padding: 10px 20px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  border-radius: var(--radius-sm);
  z-index: 200;
  transition: top 0.2s;
  text-decoration: none;
}
.skip-nav:focus {
  top: 12px;
}

/* ── Header ── */
.app-header {
  background: linear-gradient(135deg, #1a1825 0%, #0f0e17 100%);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.breadcrumb {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.breadcrumb:hover {
  color: var(--text-dim);
}

.app-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-icon {
  color: var(--accent);
  font-size: 1.2rem;
}

.version-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
  opacity: 0.7;
  margin-left: 4px;
  letter-spacing: 0.05em;
}

.app-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-icon:hover {
  border-color: var(--border-focus);
  color: var(--text);
  background: var(--bg-card-alt);
}

.btn-donate:hover {
  border-color: var(--coral);
  color: var(--coral);
}

/* ── Main ── */
.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Input Section ── */
.input-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.input-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.input-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.input-actions {
  display: flex;
  gap: 8px;
}

.btn-secondary {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card-alt);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover {
  border-color: var(--border-focus);
  color: var(--text);
  background: var(--bg-card);
}

.poem-input {
  width: 100%;
  min-height: 140px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.7;
  padding: 14px 16px;
  resize: vertical;
  transition: border-color 0.2s;
}
.poem-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.12);
}
.poem-input::placeholder {
  color: var(--text-muted);
}

.input-meta {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Controls ── */
.controls-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.btn-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.btn-option {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-option:hover {
  border-color: var(--border-focus);
  color: var(--text);
}
.btn-option.active {
  background: var(--bg-card-alt);
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* ── Results ── */
.results-section {
  min-height: 100px;
}

.results-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.results-empty p:first-child {
  font-size: 1.1rem;
  margin-bottom: 6px;
}
.results-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  opacity: 0.7;
}

.results-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Stanza / Line ── */
.stanza-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color 0.2s;
}
.line-card:hover {
  border-color: var(--border-focus);
}

.line-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.line-number {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 28px;
}

.line-meter-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(242, 183, 5, 0.1);
  padding: 2px 10px;
  border-radius: 99px;
  white-space: nowrap;
}

.line-meter-tag.irregular {
  color: var(--stress);
  background: rgba(232, 74, 95, 0.1);
}

.line-text {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--text);
  margin-bottom: 10px;
  font-family: var(--font);
}

/* ── Syllable Scansion Display ── */
.scansion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: flex-end;
  margin-bottom: 8px;
}

.syllable-unit {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: default;
  position: relative;
}

.syllable-unit .syl-text {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background 0.15s;
  white-space: nowrap;
}

.syllable-unit.stressed .syl-text {
  color: var(--stress);
  font-weight: 700;
}
.syllable-unit.secondary .syl-text {
  color: var(--secondary);
  font-weight: 600;
}
.syllable-unit.unstressed .syl-text {
  color: var(--text-dim);
}

.syllable-unit .syl-mark {
  font-size: 0.72rem;
  line-height: 1;
  height: 1em;
}
.syllable-unit.stressed .syl-mark { color: var(--stress); }
.syllable-unit.secondary .syl-mark { color: var(--secondary); }
.syllable-unit.unstressed .syl-mark { color: var(--text-muted); }

.syllable-unit .word-gap {
  display: inline-block;
  width: 10px;
  font-size: 0.82rem;
}

.syllable-unit .foot-sep {
  display: inline-block;
  width: 2px;
  height: 1.4em;
  background: var(--border);
  margin: 0 4px;
  align-self: center;
  border-radius: 1px;
}

/* ── Rhythm Strip ── */
.rhythm-strip {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 0;
  flex-wrap: wrap;
}

.pulse {
  border-radius: 50%;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.pulse.stressed {
  width: 14px;
  height: 14px;
  background: var(--stress);
  box-shadow: 0 0 8px rgba(232, 74, 95, 0.4);
}
.pulse.secondary {
  width: 11px;
  height: 11px;
  background: var(--secondary);
  opacity: 0.7;
}
.pulse.unstressed {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--text-muted);
  background: transparent;
}

.pulse-gap {
  width: 6px;
  flex-shrink: 0;
}

.pulse-foot-sep {
  width: 2px;
  height: 18px;
  background: var(--border);
  margin: 0 3px;
  border-radius: 1px;
  flex-shrink: 0;
}

/* ── Summary ── */
.summary-section {
  margin-top: 8px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.summary-value {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-mono);
}
.summary-value.stressed { color: var(--stress); }
.summary-value.unstressed { color: var(--unstressed); }
.summary-value.meter {
  font-size: 0.85rem;
  font-family: var(--font);
  color: var(--accent);
  font-weight: 600;
}

/* ── Footer ── */
.app-footer {
  text-align: center;
  padding: 24px 20px 32px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.app-footer p {
  margin-bottom: 12px;
}

.kofi-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 24px;
  border-radius: 99px;
  border: 1px solid rgba(240, 112, 82, 0.3);
  background: rgba(240, 112, 82, 0.06);
  backdrop-filter: blur(8px);
  text-decoration: none;
  transition: all 0.25s;
}
.kofi-badge:hover {
  border-color: rgba(240, 112, 82, 0.6);
  background: rgba(240, 112, 82, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(240, 112, 82, 0.15);
}

.kofi-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.kofi-text {
  font-weight: 700;
  font-size: 0.9rem;
  background: linear-gradient(135deg, var(--coral), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop[hidden] {
  display: none;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 28px 24px;
  position: relative;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card-alt);
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 1;
}
.modal-close:hover {
  border-color: var(--stress);
  color: var(--stress);
}

.modal-box h2 {
  font-size: 1.25rem;
  margin-bottom: 16px;
  padding-right: 40px;
}

.modal-body h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  margin: 16px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-body p {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  line-height: 1.6;
}

.modal-body ul,
.modal-body ol {
  font-size: 0.88rem;
  color: var(--text-dim);
  padding-left: 20px;
  margin-bottom: 8px;
}

.modal-body li {
  margin-bottom: 4px;
  line-height: 1.5;
}

.modal-body code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

.resource-links {
  list-style: none;
  padding: 0 !important;
}

.resource-links li {
  margin-bottom: 6px;
}

.resource-links a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.resource-links a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ── Tooltip ── */
.syllable-unit .tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.7rem;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
  margin-bottom: 4px;
}

.syllable-unit:hover .tooltip {
  display: block;
}

/* ── Responsive ── */
@media (max-width: 850px) {
  .controls-row {
    flex-direction: column;
    gap: 12px;
  }
  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 12px 16px;
  }
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .app-title {
    font-size: 1.15rem;
  }
  .app-subtitle {
    display: none;
  }
  .app-main {
    padding: 16px 12px 32px;
    gap: 16px;
  }
  .input-section {
    padding: 14px;
  }
  .input-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .input-actions {
    width: 100%;
  }
  .input-actions .btn-secondary {
    flex: 1;
    min-height: 44px;
  }
  .btn-option {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 0.78rem;
  }
  .btn-icon {
    width: 44px;
    height: 44px;
  }
  .line-card {
    padding: 12px 14px;
  }
  .line-text {
    font-size: 0.95rem;
  }
  .scansion-row {
    gap: 2px;
  }
  .syllable-unit .syl-text {
    font-size: 0.75rem;
    padding: 1px 3px;
  }
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .summary-card {
    padding: 10px;
  }
  .summary-value {
    font-size: 1.1rem;
  }
  .modal-box {
    padding: 20px 16px 16px;
    max-height: 90vh;
  }
  .modal-close {
    width: 44px;
    height: 44px;
  }
  .poem-input {
    min-height: 120px;
    font-size: 0.85rem;
  }
  .kofi-badge {
    padding: 8px 18px;
  }
}
