/*
 * stepcode: specialized tool for generating static books with interactive pseudocode.
 * Copyright (C) 2026  stepcode authors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

:root {
  --bg-color: #fdfbf7;
  --text-color: #333333;
  --accent-color: #d9463e;
  --heading-color: #111111;
  --code-bg: #ecebe6;
  --quote-border: #dcdcdc;

  --font-body: 'Merriweather', 'Georgia', serif;
  --font-heading: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  --max-width: 740px;
  --line-height: 1.7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --accent-color: #ff857f;
    --heading-color: #ffffff;
    --code-bg: #2b2b2b;
    --quote-border: #444;
  }
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: var(--line-height);
  transition:
    background-color 0.3s,
    color 0.3s;
  display: flex;
  min-height: 100vh;
}

nav {
  width: 280px;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  background-color: var(--code-bg);
  padding: 2rem 1.5rem;
  flex-shrink: 0;
  border-right: 1px solid var(--quote-border);
}

nav h3 {
  margin-top: 0;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

nav ul {
  list-style: none;
  padding-left: 1rem;
}

nav > ul {
  padding-left: 0;
}

nav li {
  margin-bottom: 0.5rem;
  font-family: var(--font-heading);
  font-size: 0.95rem;
}

nav a {
  border-bottom: none;
  color: var(--text-color);
}

nav a:hover,
nav a.active {
  color: var(--accent-color);
}

main {
  flex-grow: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 2rem;
}

@media (max-width: 768px) {
  nav {
    display: none;
  }
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  color: var(--heading-color);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  line-height: 1.3;
  font-weight: 700;
}

h1 {
  font-size: 2.5rem;
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 0.5rem;
  margin-top: 0;
}

h2 {
  font-size: 1.8rem;
}

h3 {
  font-size: 1.4rem;
}

a {
  color: var(--accent-color);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-color);
  transition: all 0.2s;
}

a:hover {
  border-bottom-style: solid;
}

p {
  margin-bottom: 1.5rem;
  text-align: justify;
  hyphens: auto;
}

ul,
ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

blockquote {
  font-style: italic;
  border-left: 4px solid var(--quote-border);
  margin: 2rem 0;
  padding: 0.5rem 0 0.5rem 1.5rem;
  opacity: 0.85;
}

code {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9em;
  background-color: var(--code-bg);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

pre {
  background-color: var(--code-bg);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

pre code {
  background-color: transparent;
  padding: 0;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
  font-family: var(--font-heading);
}

th {
  background-color: var(--code-bg);
  color: var(--heading-color);
  font-weight: 700;
  text-align: left;
  border-bottom: 2px solid var(--accent-color);
}

th,
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--quote-border);
}

.navigation {
  display: flex;
  justify-content: space-between;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--quote-border);
}

.navigation a {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--accent-color);
  border-radius: 6px;
  font-family: var(--font-heading);
  font-weight: 600;
  transition: all 0.2s;
}

.navigation a:hover {
  background-color: var(--accent-color);
  color: #fff;
}

.navigation .next {
  margin-left: auto;
}

/* Pseudo-runner styles */
.pseudo-runner {
  background-color: var(--code-bg);
  border-radius: 8px;
  margin-bottom: 2rem;
  padding: 1rem;
  border: 1px solid var(--quote-border);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pseudo-runner pre {
  margin-bottom: 0;
  padding: 0;
  background-color: transparent;
  font-size: 0.95rem;
  line-height: 1.6;
}

.pseudo-runner-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pseudo-runner button {
  background-color: var(--accent-color);
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-family: var(--font-heading);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.2;
}

.pseudo-runner button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pseudo-runner button:active {
  transform: translateY(0);
}

.pseudo-editor {
  width: 100%;
  background-color: transparent;
  color: var(--text-color);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  border: none;
  outline: none;
  resize: vertical;
  min-height: 100px;
}

.pseudo-error {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.9rem;
  background-color: rgba(217, 70, 62, 0.1);
  padding: 0.5rem;
  border-radius: 4px;
  border-left: 4px solid var(--accent-color);
}

.pseudo-runner .indicator {
  color: var(--accent-color);
  font-weight: bold;
  font-family: 'Consolas', 'Monaco', monospace;
  background-color: rgba(217, 70, 62, 0.1);
  /* Slight accent background */
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin: 0;
}

footer {
  margin-top: 4rem;
  padding: 1rem 0;
  border-top: 1px solid #ddd;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.footer-left code {
  background: transparent;
  font-weight: 600;
}

.footer-right a {
  color: inherit;
  display: flex;
  align-items: center;
  border-bottom: none;
}

.footer-right a:hover {
  opacity: 0.7;
}

@media (prefers-color-scheme: dark) {
  .pseudo-runner .indicator {
    background-color: rgba(255, 133, 127, 0.15);
  }
}
