/* =========================================================
   Think–Write–Share  –  clean, calm, accessible stylesheet
   ========================================================= */

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

:root {
  --bg:          #f5f6f8;
  --surface:     #ffffff;
  --border:      #d8dde6;
  --text:        #1a1e2e;
  --text-muted:  #5a6378;
  --primary:     #2a6496;
  --primary-dk:  #1e4d73;
  --danger:      #c0392b;
  --danger-dk:   #962d22;
  --success:     #276b4e;
  --success-bg:  #e8f5ef;
  --warn:        #7a5c00;
  --warn-bg:     #fef9e7;
  --timer-color: #1a3a5c;
  --radius:      8px;
  --shadow:      0 2px 8px rgba(0,0,0,.08);
}

html { font-size: 18px; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); }
a:hover { color: var(--primary-dk); }

/* --- Layout ------------------------------------------------ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
}
.site-logo {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -.01em;
}
.site-logo:hover { color: var(--primary); }

.main-content {
  flex: 1;
  padding: 2rem 1rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: .8rem;
  border-top: 1px solid var(--border);
}

/* --- Cards ------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

/* --- Typography ------------------------------------------- */
h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .5rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; color: var(--text-muted); }
.label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .25rem;
}
.intro { color: var(--text-muted); margin-bottom: 1.5rem; }
.muted { color: var(--text-muted); }

/* --- Forms ------------------------------------------------- */
.field { margin-bottom: 1.5rem; }
.field label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .4rem;
}
input[type="text"],
textarea,
select {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42,100,150,.18);
}
textarea { resize: vertical; }
.field-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

/* Slug row */
.slug-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.slug-prefix {
  font-family: monospace;
  font-size: .95rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.slug-row input { flex: 1; font-family: monospace; }
.slug-hint { min-height: 1.2em; }
.slug-hint.ok  { color: var(--success); }
.slug-hint.err { color: var(--danger); }

/* --- Buttons ---------------------------------------------- */
.btn-primary, .btn-secondary, .btn-danger, .btn-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dk); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: var(--danger-dk); }
.btn-download { background: var(--success); color: #fff; }
.btn-download:hover { background: #1e5a3e; color: #fff; }
.btn-large  { font-size: 1.05rem; padding: .7rem 1.6rem; }
.btn-small  { font-size: .8rem; padding: .3rem .7rem; }
.btn-action { width: 100%; margin-bottom: .75rem; text-align: center; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* --- Error / success boxes -------------------------------- */
.error-box {
  background: #fdf0ef;
  border: 1px solid #e8a39c;
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  margin-bottom: 1.5rem;
  color: var(--danger);
  font-size: .9rem;
}
.error-box p { margin-bottom: .25rem; }
.error-box p:last-child { margin-bottom: 0; }

.success-box {
  background: var(--success-bg);
  border: 1px solid #a3d9bc;
  border-left: 4px solid var(--success);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  color: var(--success);
}

/* --- Home / landing page ---------------------------------- */
.home-page { display: flex; flex-direction: column; gap: 2.5rem; }

/* Academic-serif title — Computer Modern for LaTeX users, Palatino for everyone else */
.home-title {
  font-family: "CMU Serif", "Computer Modern", "Palatino Linotype",
               "Book Antiqua", Palatino, Georgia, serif;
  font-size: 2.4rem;
  font-weight: 400;     /* CM looks better at regular weight */
  letter-spacing: -.01em;
  margin-bottom: .55rem;
}

.home-hero { text-align: center; padding: 1.25rem 0 .25rem; }
.home-tagline {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.65;
}

/* Three stage cards */
.stages {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 620px) {
  .stages { grid-template-columns: 1fr; }
}

.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;       /* clip the icon area corners */
}

/* Coloured icon band at top of each card */
.stage-icon-area {
  background: rgba(42, 100, 150, .07);
  border-bottom: 1px solid rgba(42, 100, 150, .12);
  padding: 1.4rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
}

.stage-icon {
  width: 36px;
  height: 36px;
  color: var(--primary);
  flex-shrink: 0;
}

.stage-name {
  font-family: "CMU Serif", "Computer Modern", "Palatino Linotype",
               "Book Antiqua", Palatino, Georgia, serif;
  font-size: .8rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--primary);
}

.stage-desc {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 1rem 1.1rem 1.2rem;
}

/* Benefits list */
.benefits {
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.benefits li {
  padding-left: 1.5rem;
  position: relative;
  font-size: .88rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.benefits li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 400;
}

/* CTA area */
.home-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding-bottom: .5rem;
}

/* Join section */
.join-section { text-align: center; }
.join-prompt {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.join-error {
  font-size: .85rem;
  color: var(--danger);
  margin-bottom: .5rem;
}
.join-form {
  display: flex;
  gap: .5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.join-form input[type="text"] {
  width: auto;
  flex: 1;
  min-width: 210px;
  max-width: 300px;
  font-family: monospace;
  font-size: .9rem;
}

/* --- Create page ------------------------------------------ */
.create-card h1 { margin-bottom: .25rem; }

/* --- Participant page -------------------------------------- */
.participant-page { display: flex; flex-direction: column; gap: 2rem; }

.question-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
}
.question-text {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
}
/* On admin page the question is shown without banner */
.admin-header .question-text {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: .3rem;
}

.status-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
}

.status-msg {
  font-size: 1.05rem;
  color: var(--text-muted);
}
.loading-msg { color: var(--text-muted); }

/* Timer */
.timer-area { text-align: center; }
.timer-label {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.timer-display {
  font-size: 4.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--timer-color);
  line-height: 1;
  letter-spacing: -.03em;
}
.timer-display.urgent { color: var(--danger); }

/* Answer form */
.answer-form { width: 100%; text-align: left; }
.answer-form label {
  display: block;
  font-weight: 600;
  margin-bottom: .5rem;
}
.answer-form textarea {
  width: 100%;
  margin-bottom: .5rem;
}
.char-count {
  text-align: right;
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: .75rem;
}
.answer-hint { font-size: .82rem; color: var(--text-muted); margin-top: .5rem; }

/* Submitted message */
.submitted-msg { text-align: center; }
.submitted-msg .icon { font-size: 2.5rem; margin-bottom: .5rem; }

/* Revealed answer */
.revealed-answer { width: 100%; text-align: left; }
.revealed-answer blockquote {
  background: var(--bg);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.25rem 1.5rem;
  font-size: 1.1rem;
  line-height: 1.6;
  margin: .75rem 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.revealed-hint {
  font-size: .82rem;
  color: var(--text-muted);
  text-align: center;
}
.no-answers { font-size: 1rem; color: var(--text-muted); }

/* --- Admin page ------------------------------------------- */
.admin-page { display: flex; flex-direction: column; gap: 1.5rem; }

.admin-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
}
.admin-header h1 { font-size: 1.3rem; margin-bottom: .15rem; color: var(--text-muted); font-weight: 600; }

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 600px) {
  .admin-grid { grid-template-columns: 1fr; }
}

.admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* Status definitions list */
.status-dl { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; align-items: start; }
.status-dl dt {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  padding-top: .2rem;
}
.status-dl dd { font-size: .95rem; }

/* Status badge */
.status-badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.status-waiting  { background: #e8ecf5; color: #3a4a6b; }
.status-thinking { background: var(--warn-bg); color: var(--warn); }
.status-writing  { background: #e8f5ef; color: var(--success); }
.status-closed   { background: #f0f0f0; color: #555; }

/* Participant URL */
.participant-url-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.participant-url {
  font-family: monospace;
  font-size: .85rem;
  word-break: break-all;
}
.copy-feedback { font-size: .78rem; color: var(--success); }

/* Answer count */
.answer-count { font-size: 1.5rem; font-weight: 700; color: var(--primary); }

/* Admin timer display */
.admin-timer { font-size: 2.5rem; font-weight: 700; color: var(--timer-color); font-variant-numeric: tabular-nums; }

/* Action buttons */
.action-buttons { display: flex; flex-direction: column; }
.closed-notice { color: var(--text-muted); font-size: .9rem; margin-bottom: .75rem; }

/* Admin details summary */
.admin-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
}
.admin-details summary {
  cursor: pointer;
  font-size: .85rem;
  color: var(--text-muted);
  font-weight: 600;
}
.admin-details[open] summary { margin-bottom: .75rem; }

/* --- Error page ------------------------------------------- */
.error-page { text-align: center; }
.error-page h1 { font-size: 4rem; color: var(--text-muted); }
.error-page p { margin: 1rem 0 1.5rem; }
