/* ══════════════════════════════════════════════
   kvedjur.is — styles
   Fonts: Playfair Display (headings) + Lato (body)
   Palette: dark midnight / gold (scheme B)
   Four template overrides at bottom
   ══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=Lato:wght@300;400;700&display=swap');

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

:root {
  --bg:          #0f1b2d;
  --bg-mid:      #162236;
  --bg-deep:     #0a1220;
  --border:      #1e3050;
  --gold:        #c9a84c;
  --gold-light:  #e8c96a;
  --gold-bg:     rgba(201,168,76,0.10);
  --text:        #f0ece6;
  --text-mid:    #c0b8ac;
  --text-soft:   #8090a8;
  --error:       #e05c5c;
  --success:     #5cba6a;
  --radius:      8px;
  --shadow:      0 2px 16px rgba(0,0,0,0.35);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Lato', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: 'Playfair Display', serif;
  line-height: 1.25;
}

a { color: var(--gold); }
a:hover { color: var(--gold-light); }

/* ── Layout ───────────────────────────────────── */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header ───────────────────────────────────── */
.site-header {
  background: rgba(15,27,45,0.95);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.site-logo span { color: var(--gold); }
#header-auth {
  display: none;
  align-items: center;
  gap: 16px;
  font-size: 0.875rem;
  color: var(--text-soft);
}

/* ── Screens ──────────────────────────────────── */
.screen { display: none; padding: 40px 0 60px; }
.screen.active { display: block; }

/* ── Buttons ──────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-family: 'Lato', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--bg);
  letter-spacing: 0.02em;
}
.btn-primary:hover:not(:disabled) { opacity: 0.88; }
.btn-secondary {
  background: transparent;
  color: var(--text-mid);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--gold); color: var(--text); }
.btn-link {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 2px 0;
  text-decoration: underline;
}
.btn-link:hover { color: var(--gold-light); }
.btn-danger { color: var(--error); }
.btn-full { width: 100%; text-align: center; }

/* ── Forms ────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.date-input-wrap { position: relative; display: flex; align-items: center; }
.date-input-wrap input[type="text"] { flex: 1; padding-right: 44px; }
.date-input-wrap input[type="date"] { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.date-cal-btn { position: absolute; right: 10px; background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 4px; line-height: 1; color: var(--text-soft); }
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--text-soft);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Lato', sans-serif;
  font-size: 0.95rem;
  background: var(--bg-mid);
  color: var(--text);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.form-group select option { background: var(--bg-mid); }
.form-group textarea { resize: vertical; min-height: 120px; }
.form-hint { font-size: 0.8rem; color: var(--text-soft); margin-top: 4px; }

.error-msg {
  display: none;
  color: var(--error);
  font-size: 0.875rem;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(224,92,92,0.10);
  border-radius: var(--radius);
  border-left: 3px solid var(--error);
}
.error-text { color: var(--error); font-size: 0.875rem; }
.loading-text { color: var(--text-soft); font-style: italic; }
.empty-state { color: var(--text-soft); font-size: 0.9rem; padding: 20px 0; }

/* ── Card ─────────────────────────────────────── */
.card {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ── Login screen ─────────────────────────────── */
#screen-login { max-width: 400px; margin: 0 auto; padding-top: 60px; }
#screen-login .card { margin-top: 32px; }
#screen-login h1 { text-align: center; margin-bottom: 8px; color: var(--text); }
#screen-login .subtitle { text-align: center; color: var(--text-soft); margin-bottom: 28px; font-size: 0.9rem; }
.login-toggle { text-align: center; margin-top: 16px; font-size: 0.875rem; }

/* ── Dashboard screen ─────────────────────────── */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.screen-header h2 { font-size: 1.6rem; color: var(--text); }

.book-card {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.book-card:hover { box-shadow: var(--shadow); border-color: rgba(201,168,76,0.3); }
.book-card h3 { font-size: 1.05rem; margin-bottom: 2px; color: var(--text); }
.book-meta { font-size: 0.8rem; color: var(--text-soft); }
.book-card-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

.status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}
.status-collecting { background: rgba(92,186,106,0.15); color: #5cba6a; }
.status-locked     { background: rgba(230,126,0,0.15);  color: #e67e00; }
.status-compiled   { background: rgba(201,168,76,0.15); color: var(--gold); }
.status-unpaid     { background: rgba(180,80,0,0.15);  color: #d4700a; }

/* ── New book screen ──────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text-soft);
  margin-bottom: 24px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.back-link:hover { color: var(--gold); }

/* ── Book detail screen ───────────────────────── */
.detail-header { margin-bottom: 28px; }
.detail-header h2 { font-size: 1.5rem; color: var(--text); }
.detail-header .book-meta { margin-top: 4px; }

.share-box {
  background: var(--gold-bg);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.share-box h4 { font-size: 0.95rem; margin-bottom: 10px; color: var(--text-mid); }
.share-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.share-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
}
.pin-display { font-size: 0.875rem; color: var(--text-mid); }
.pin-display strong { color: var(--gold); font-size: 1rem; letter-spacing: 0.1em; }

.contributions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.contributions-header h3 { font-size: 1.05rem; color: var(--text); }
.contrib-count { font-size: 0.8rem; color: var(--text-soft); }

.contribution-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--bg-mid);
  transition: opacity 0.2s;
}
.contribution-removed { opacity: 0.35; }
.contribution-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.contributor-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.contribution-date { font-size: 0.75rem; color: var(--text-soft); }
.contribution-text { font-size: 0.9rem; line-height: 1.55; word-break: break-word; color: var(--text-mid); }
.contribution-text[contenteditable="true"] {
  border-bottom: 1.5px dashed var(--gold);
  outline: none;
  padding-bottom: 2px;
}
.contribution-actions { margin-top: 8px; display: flex; gap: 12px; }

.payment-notice { background: rgba(180,80,0,0.1); border: 1px solid rgba(180,80,0,0.25); border-radius: 8px; padding: 14px 18px; margin-bottom: 20px; }
.payment-notice p { font-size: 14px; color: #d4700a; margin: 0; }
.compile-section { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 20px; }
.compile-section p { font-size: 0.875rem; color: var(--text-soft); margin-bottom: 14px; }

/* ── Compile loading screen ───────────────────── */
#screen-compile-loading {
  text-align: center;
  padding-top: 120px;
}
.spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#screen-compile-loading h3 { font-family: 'Playfair Display', serif; color: var(--text-mid); }
#screen-compile-loading p { color: var(--text-soft); font-size: 0.9rem; margin-top: 8px; }

/* ── Output / template screen ─────────────────── */
.output-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.template-selector { margin-bottom: 24px; }
.template-selector h4 { font-size: 0.9rem; color: var(--text-mid); margin-bottom: 10px; }
.template-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  background: var(--bg-mid);
  color: var(--text-mid);
  transition: border-color 0.15s;
}
.template-option input { margin-top: 2px; accent-color: var(--gold); }
.template-option.selected { border-color: var(--gold); background: var(--gold-bg); }
.template-option strong { color: var(--text); }

/* ── Output container (screen) ────────────────── */
.output-preview { margin-top: 20px; }
.output-container {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  font-family: 'Playfair Display', serif;
}
.output-header { padding: 48px 40px 36px; }
.output-template-label {
  font-family: 'Lato', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
  opacity: 0.7;
}
.output-headline { font-size: 2rem; line-height: 1.2; margin-bottom: 10px; }
.output-subheadline { font-size: 1rem; opacity: 0.8; font-style: italic; }
.output-body { padding: 32px 40px; }
.output-narrative p { font-size: 1rem; line-height: 1.8; margin-bottom: 16px; font-family: 'Lato', sans-serif; }
.output-quotes { margin-top: 28px; padding-top: 20px; border-top: 1px solid rgba(0,0,0,0.08); }
.featured-quote {
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 14px;
  padding-left: 18px;
  border-left: 3px solid;
}
.output-footer {
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-family: 'Lato', sans-serif;
}
.output-meta { opacity: 0.6; }
.output-brand { opacity: 0.4; letter-spacing: 0.05em; }

/* ── Template: celebration (Gleði) ──────────────
   Warm gold / amber */
.template-celebration .output-header { background: #f5e6c0; color: #3a2e1e; }
.template-celebration .output-body   { background: #fffbf0; color: #3a2e1e; }
.template-celebration .output-footer { background: #ede0b0; color: #6b5a44; }
.template-celebration .featured-quote { border-color: #b8860b; }

/* ── Template: memorial (Minning) ────────────────
   Deep forest green */
.template-memorial .output-header { background: #2d5016; color: #f0f8ec; }
.template-memorial .output-body   { background: #f5f8f5; color: #1a2e12; }
.template-memorial .output-footer { background: #e8f0e6; color: #3a5028; }
.template-memorial .output-subheadline { opacity: 0.85; }
.template-memorial .featured-quote { border-color: #4a7a28; color: #2d5016; }

/* ── Template: milestone (Vegferð) ──────────────
   Bold black editorial */
.template-milestone .output-header { background: #1a1a1a; color: #ffffff; }
.template-milestone .output-body   { background: #ffffff; color: #1a1a1a; }
.template-milestone .output-footer { background: #f0f0f0; color: #666; }
.template-milestone .output-headline { font-size: 2.2rem; letter-spacing: -0.01em; }
.template-milestone .featured-quote { border-color: #1a1a1a; }

/* ── Template: farewell (Kveðja) ─────────────────
   Soft rose / blush */
.template-farewell .output-header { background: #f5d0dc; color: #4a1e2e; }
.template-farewell .output-body   { background: #fff8f8; color: #3a1e2a; }
.template-farewell .output-footer { background: #edc8d4; color: #7a4060; }
.template-farewell .featured-quote { border-color: #c06080; color: #7a2040; }

/* ── Template: other (Önnur tilefni) ─────────────
   Deep indigo / steel blue */
.template-other .output-header { background: #1e2a4a; color: #eef1f8; }
.template-other .output-body   { background: #f5f6fa; color: #1e2a4a; }
.template-other .output-footer { background: #e8ecf5; color: #4a5a80; }
.template-other .featured-quote { border-color: #5c7ab8; color: #2a3a5a; }

/* ── Contribute page ──────────────────────────── */
.contribute-wrap { max-width: 560px; margin: 0 auto; padding: 32px 20px 60px; }

.occasion-card {
  background: var(--gold-bg);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 10px;
  padding: 22px 24px;
  margin-bottom: 24px;
  text-align: center;
}
.occasion-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.occasion-card h2 {
  font-size: 1.7rem;
  color: var(--text);
  margin-bottom: 6px;
}
.organiser-note { font-size: 0.875rem; color: var(--text-mid); margin-bottom: 4px; }
.deadline-note { font-size: 0.8rem; color: var(--text-soft); }

.privacy-note {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-bottom: 18px;
  line-height: 1.5;
}

.char-counter {
  text-align: right;
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-top: 4px;
}
.char-counter.near-limit { color: #e67e00; }
.char-counter.at-limit   { color: var(--error); }

.field-optional {
  font-weight: 400;
  font-size: 0.8em;
  color: var(--text-soft);
}
.field-hint {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: 5px;
}

.anon-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-mid);
  margin-bottom: 20px;
}
.anon-row input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; }

.confirm-box {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.confirm-box h4 { font-size: 0.9rem; color: var(--text-mid); margin-bottom: 8px; }
.confirm-box p { font-size: 0.95rem; line-height: 1.6; font-style: italic; color: var(--text); }

.closed-notice {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-soft);
}
.closed-notice h3 { font-size: 1.3rem; margin-bottom: 8px; color: var(--text-mid); }

/* ── PIN screen ───────────────────────────────── */
.pin-screen { text-align: center; padding: 40px 20px; }
.pin-screen h3 { margin-bottom: 8px; color: var(--text); }
.pin-screen p  { font-size: 0.9rem; color: var(--text-soft); margin-bottom: 24px; }
.pin-input {
  font-size: 2rem;
  letter-spacing: 0.3em;
  text-align: center;
  width: 160px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-mid);
  color: var(--text);
  margin-bottom: 16px;
}
.pin-input:focus { outline: none; border-color: var(--gold); }

/* ── Print / PDF styles ───────────────────────── */
@media print {
  body * { visibility: hidden; }

  .output-container,
  .output-container * { visibility: visible; }

  .output-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    box-shadow: none;
    border-radius: 0;
  }

  /* Ensure background colours print */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 600px) {
  .output-header { padding: 32px 24px 24px; }
  .output-body   { padding: 24px 24px; }
  .output-footer { padding: 14px 24px; }
  .output-headline { font-size: 1.5rem; }
  .screen-header { flex-direction: column; align-items: flex-start; }
  .book-card { flex-direction: column; align-items: flex-start; }
  .book-card-right { width: 100%; justify-content: space-between; }
}
