﻿/* ── 16×16 London Poem — styles (plain HTML port) ─────────── */
/* Google Fonts loaded via <link> in index.html — not @import to avoid render blocking */

/* ── Design tokens — dark (default) ────────────────────────── */
:root,
html[data-theme="dark"] {
  --bg:        #07090f;
  --surface:   #0f1219;
  --surface-2: #171c27;
  --border:    #1e2535;
  --text:      #ede8df;
  --text-dim:  #8891a4;
  --text-faint:#3d4557;
  --accent:    #c9a84c;
  --accent-dim:#8a6e2e;
  --green:     #4caf7a;
  --red:       #e05555;
  --highlight: rgba(201,168,76,0.18);

  --font-poem: 'Playfair Display', Georgia, serif;
  --font-ui:   'DM Mono', 'Courier New', monospace;
  --font-body: 'Libre Baskerville', Georgia, serif;

  --radius:  4px;
  --max-w:   680px;
}

/* ── Design tokens — light ──────────────────────────────────── */
html[data-theme="light"] {
  --bg:        #faf7f2;
  --surface:   #f0ebe0;
  --surface-2: #e8e0d0;
  --border:    #d4c9b0;
  --text:      #1a160e;
  --text-dim:  #5c5040;
  --text-faint:#a89880;
  --accent:    #8a5a10;
  --accent-dim:#b07820;
  --green:     #276b42;
  --red:       #b03030;
  --highlight: rgba(138,90,16,0.12);
}

/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

/* Fallback font metrics — minimise layout shift when web fonts swap in */
@font-face {
  font-family: 'Playfair Display';
  src: local('Georgia');
  font-style: normal;
  font-weight: 400 600;
  size-adjust: 102%;
  ascent-override: 90%;
  font-display: swap;
}
@font-face {
  font-family: 'Libre Baskerville';
  src: local('Georgia');
  font-style: normal;
  font-weight: 400;
  size-adjust: 99%;
  font-display: swap;
}
@font-face {
  font-family: 'DM Mono';
  src: local('Courier New');
  font-style: normal;
  font-weight: 300 400;
  size-adjust: 85%;
  font-display: swap;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100dvh;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ── Theme toggle ────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  transition: border-color 0.15s, color 0.15s;
  user-select: none;
}
.theme-toggle:hover { border-color: var(--accent-dim); color: var(--text); }
.theme-toggle-ico { font-size: 0.9rem; line-height: 1; }

/* ── Navigation ─────────────────────────────────────────────── */
.nav {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  min-height: 3.25rem; /* reserve space — prevents CLS when fonts load */
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  backdrop-filter: blur(8px);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav-brand {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}
.nav-brand:hover { opacity: 0.8; text-decoration: none; }

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.nav-links a {
  color: var(--text-dim);
  transition: color 0.15s;
  cursor: pointer;
}
.nav-links a:hover,
.nav-links a.active { color: var(--text); text-decoration: none; }

/* ── Views ───────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.eyebrow {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
  display: block;
}
.page-title {
  font-family: var(--font-poem);
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.page-title em { font-style: italic; color: var(--accent); }

.poem-meta-row {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-dim);
}
.meta-left {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.meta-flags {
  display: flex;
  gap: 0.2rem;
  align-items: center;
  flex-shrink: 0;
}
.meta-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.2rem 0.6rem;
}
.meta-pill.status-completed  { border-color: var(--green); color: var(--green); }
.meta-pill.status-active     { border-color: var(--accent-dim); color: var(--accent); }
.meta-pill.status-unfinished { border-color: var(--text-faint); color: var(--text-faint); }

/* ── Country flags (inline in meta pill) ────────────────────── */
.country-flag {
  font-size: 1rem;
  line-height: 1;
  cursor: default;
  transition: transform 0.1s;
  display: inline-block;
}
.country-flag:hover { transform: scale(1.3); }

/* ── Progress bar ────────────────────────────────────────────── */
.word-count-label {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.poem-progress-bar {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  margin: 1rem 0;
  overflow: hidden;
}
.poem-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 0.5s ease;
}

/* ── Poem display ────────────────────────────────────────────── */
.poem-block {
  font-family: var(--font-poem);
  font-size: clamp(1.05rem, 2.5vw, 1.2rem);
  line-height: 1.9;
  color: var(--text);
  padding: 1.5rem 0;
  /* Reserve space for ~16 rows so skeleton→content swap doesn't shift page */
  min-height: 34rem;
  contain: layout style;
}
.poem-row { display: block; min-height: 1.9em; }
.poem-row-number {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  color: var(--text-faint);
  margin-right: 0.75rem;
  user-select: none;
  display: inline-block;
  width: 1.5em;
  text-align: right;
}
.poem-word { display: inline; }
.poem-word + .poem-word::before { content: ' '; }
.poem-word.is-new {
  color: var(--accent);
  animation: wordReveal 0.5s ease-out forwards;
}
.poem-word.was-edited { font-style: italic; }

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

/* ── Input area ──────────────────────────────────────────────── */
.input-section {
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--border);
}
.input-prompt {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
  display: block;
}
.word-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.word-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-family: var(--font-poem);
  font-size: 1.1rem;
  color: var(--text);
  transition: border-color 0.15s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.word-input:focus { border-color: var(--accent-dim); background: var(--surface-2); }
.word-input::placeholder { color: var(--text-faint); }

.submit-btn {
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 400;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.submit-btn:hover:not(:disabled) { opacity: 0.85; }
.submit-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.input-error {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--red);
  margin-top: 0.5rem;
}

/* ── Edit window ─────────────────────────────────────────────── */
.edit-banner {
  background: var(--surface);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.edit-banner-label {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-dim);
}
.edit-countdown {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--accent);
  min-width: 2rem;
}
.edit-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
  margin-top: 0.5rem;
}
.edit-save-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.85rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text);
  transition: border-color 0.15s;
}
.edit-save-btn:hover { border-color: var(--accent-dim); }

/* ── Status messages ─────────────────────────────────────────── */
.status-message {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid;
}
.status-message.info    { background: var(--surface); border-color: var(--border); color: var(--text-dim); }
.status-message.success { background: rgba(76,175,122,0.08); border-color: rgba(76,175,122,0.3); color: var(--green); }
.status-message.warning { background: rgba(201,168,76,0.08); border-color: var(--accent-dim); color: var(--accent); }

/* ── Share card ──────────────────────────────────────────────── */
.share-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
}
.share-card-title {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}
.share-card-headline {
  font-family: var(--font-poem);
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.share-card-headline strong { color: var(--accent); }
.share-card-date {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
}
.share-card-excerpt {
  font-family: var(--font-poem);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-dim);
  border-left: 2px solid var(--accent-dim);
  padding-left: 0.75rem;
  margin-bottom: 1rem;
  line-height: 1.6;
}
.share-card-excerpt .highlighted-word {
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}
.share-card-footer {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.share-btn {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
  cursor: pointer;
}
.share-btn:hover { border-color: var(--accent-dim); color: var(--text); text-decoration: none; }

.share-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* X / Twitter */
.share-btn--x { border-color: #333; }
.share-btn--x:hover { background: #000; border-color: #555; color: #fff; }

/* Facebook */
.share-btn--fb { border-color: #1a3a6c; }
.share-btn--fb:hover { background: #1877f2; border-color: #1877f2; color: #fff; }

/* LinkedIn */
.share-btn--li { border-color: #0a4b78; }
.share-btn--li:hover { background: #0a66c2; border-color: #0a66c2; color: #fff; }

/* ── Poem complete banner ────────────────────────────────────── */
.poem-complete-banner {
  text-align: center;
  padding: 2rem 1rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}
.poem-complete-banner .banner-title {
  font-family: var(--font-poem);
  font-size: 1.3rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.poem-complete-banner .banner-sub {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ── Archive list ────────────────────────────────────────────── */
.archive-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.archive-item {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.12s;
  border-radius: 2px;
  cursor: pointer;
}
.archive-item:hover { background: var(--surface); text-decoration: none; }
.archive-num {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--accent);
  text-align: right;
}
.archive-info { min-width: 0; }
.archive-date {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.15rem;
}
.archive-words {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  color: var(--text-faint);
}
.archive-status {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
  border: 1px solid var(--border);
  color: var(--text-faint);
}
.archive-status.done { border-color: var(--green); color: var(--green); }

/* ── Single poem view (archive detail) ──────────────────────── */
.back-link {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-block;
  margin-bottom: 1.5rem;
}
.back-link:hover { color: var(--text); }

/* ── Stats ───────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.stat-value {
  font-family: var(--font-poem);
  font-size: 1.75rem;
  color: var(--text);
  line-height: 1;
  margin-bottom: 0.3rem;
}
.stat-label {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ── Loading skeleton ────────────────────────────────────────── */
.skeleton-line {
  height: 1.2em;
  background: var(--surface);
  border-radius: 2px;
  /* match poem-block line height so skeleton holds same vertical space */
  margin: 0.65em 0;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%   { opacity: 0.5; }
  50%  { opacity: 1; }
  100% { opacity: 0.5; }
}

/* ── Footer ──────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  padding: 1.5rem 0 2rem;
  min-height: 5rem;
  contain: layout style;
}
.footer-inner {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
}
.footer-privacy {
  opacity: 0.6;
  font-size: 0.6rem;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .poem-block { font-size: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .archive-item { grid-template-columns: 2rem 1fr auto; gap: 0.75rem; }
}
