/* =========================================================
   Nyctography – styles
   ========================================================= */

:root {
  --bg:         #f5f4f0;
  --fg:         #1c1a18;
  --accent:     #5c3d2e;
  --accent-lt:  #7a5240;
  --surface:    #ffffff;
  --surface-hover: #f0ece6;
  --border:     #d0c8be;
  --muted:      #7a7268;
  --link:       #8b5e3c;
  --active:     #5c3d2e;

  --radius:     6px;
  --max-w:      900px;
}

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

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.75;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
}

/* ----- Header ----- */
header {
  text-align: center;
  padding: 3.5rem 0 2rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  color: var(--accent);
  letter-spacing: 0.12em;
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

.subtitle {
  font-style: italic;
  color: var(--muted);
  font-size: 1.05rem;
}

/* ----- Main layout ----- */
main { padding: 2.5rem 0; }

section {
  margin-bottom: 3.5rem;
}

h2 {
  font-size: 1.6rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 1.25rem;
}

p { margin-bottom: 1rem; }

.section-hint {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

blockquote {
  border-left: 4px solid var(--accent);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: #ede8e1;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
}

blockquote cite {
  display: block;
  margin-top: 0.6rem;
  font-style: normal;
  font-size: 0.88rem;
  color: var(--muted);
}

/* ----- Alphabet grid ----- */
.alphabet-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.char-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.4rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 56px;
  cursor: default;
  transition: background 0.15s, box-shadow 0.15s;
}

.char-cell:hover {
  background: var(--surface-hover);
  box-shadow: 0 2px 6px rgba(0,0,0,0.09);
}

.char-symbol {
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.25rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  letter-spacing: 0.04em;
}

/* ----- Encoder ----- */
.encoder-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

label {
  font-weight: bold;
  font-size: 0.95rem;
}

textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  background: var(--surface);
  color: var(--fg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(92, 61, 46, 0.15);
}

button {
  align-self: flex-start;
  padding: 0.55rem 1.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover { background: var(--accent-lt); }
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
button.secondary:hover {
  background: var(--surface-hover);
}

/* Encoder output */
.output-container {
  margin-top: 1.5rem;
  min-height: 80px;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.encoded-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: flex-end;
}

.encoded-cell {
  cursor: default;
}

.char-spacer {
  width: 1.25rem;
  height: 68px;
  display: inline-block;
}

.output-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
}

.output-unknown {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: 'Courier New', monospace;
  align-self: center;
  padding: 0 0.15rem;
}

/* ----- Decoder ----- */
.decoder-container {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  flex-wrap: wrap;
}

.decoder-grid-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  flex-shrink: 0;
}

/* SVG elements */
#decoder-svg .dot {
  fill: var(--border);
  cursor: pointer;
  transition: fill 0.1s;
}
#decoder-svg .dot-fixed {
  fill: var(--fg);
  cursor: default;
}
#decoder-svg .dot-optional:hover {
  fill: var(--accent-lt);
}
#decoder-svg .dot-optional.active {
  fill: var(--fg);
}
#decoder-svg .dot-optional[aria-pressed="true"] {
  fill: var(--fg);
}

#decoder-svg .side {
  stroke: var(--border);
  stroke-width: 3;
  stroke-linecap: round;
  cursor: pointer;
  transition: stroke 0.1s;
}
#decoder-svg .side:hover {
  stroke: var(--accent-lt);
}
#decoder-svg .side.active,
#decoder-svg .side[aria-pressed="true"] {
  stroke: var(--fg);
}

#decoder-svg .hit-area {
  stroke: transparent;
  stroke-width: 18;
  cursor: pointer;
  fill: none;
}

.decoder-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.decoded-char {
  font-size: 5rem;
  font-weight: bold;
  color: var(--accent);
  line-height: 1;
  min-width: 80px;
  text-align: center;
  font-family: Georgia, serif;
}

.decoded-desc {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  max-width: 180px;
}

/* ----- Resources ----- */
ul {
  padding-left: 1.4rem;
}
li { margin-bottom: 0.5rem; }

a {
  color: var(--link);
  text-decoration: none;
}
a:hover { text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ----- Footer ----- */
footer {
  text-align: center;
  padding: 2rem 0 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 1rem;
}
footer p { margin-bottom: 0.4rem; }

/* ----- Responsive ----- */
@media (max-width: 600px) {
  .char-cell { min-width: 48px; }
  .decoder-container { gap: 1.5rem; }
  .decoded-char { font-size: 4rem; }
}
