@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --paper: #EFF3F5;
  --paper-line: #D7DEE3;
  --ink: #16202B;
  --navy: #1B2A4A;
  --amber: #E8A33D;
  --amber-dark: #C7811F;
  --moss: #4C7A5A;
  --card-bg: #FBFCFD;
  --max-width: 720px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px);
  background-size: 28px 28px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: 'Source Serif 4', serif;
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 0.5em;
  line-height: 1.2;
}

h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; }

p { max-width: 62ch; }

a {
  color: var(--navy);
  text-decoration-color: var(--amber);
  text-decoration-thickness: 2px;
}

a:hover { color: var(--amber-dark); }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
header {
  border-bottom: 2px solid var(--navy);
  background: var(--paper);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}

.site-title {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--navy);
  text-decoration: none;
}

nav {
  display: flex;
  gap: 24px;
}

nav a {
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
}

nav a:hover,
nav a.active {
  border-bottom-color: var(--amber);
  color: var(--navy);
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px 64px;
}


/* Dark mode */
[data-theme="dark"] {
  --paper: #16202B;
  --paper-line: #2A3A4A;
  --ink: #E4E9ED;
  --navy: #E8A33D;
  --card-bg: #1D2934;
}

[data-theme="dark"] .site-title { color: var(--navy); }
[data-theme="dark"] button { color: var(--paper); }
[data-theme="dark"] #response,
[data-theme="dark"] textarea {
  background: #101820;
  color: var(--ink);
  border-color: var(--paper-line);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--paper-line);
  color: var(--ink);
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  margin: 0;
}

.theme-toggle:hover {
  border-color: var(--amber);
}

/* Card / notebook entry styling */
.entry {
  background: var(--card-bg);
  border-left: 4px solid var(--amber);
  border-top: 1px solid var(--paper-line);
  border-right: 1px solid var(--paper-line);
  border-bottom: 1px solid var(--paper-line);
  padding: 24px 28px;
  margin-bottom: 24px;
}

.entry-label {
  font-size: 0.75rem;
  color: var(--moss);
  margin-bottom: 8px;
  display: block;
}

/* Form elements */
textarea {
  width: 100%;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.95rem;
  padding: 12px;
  border: 1px solid var(--paper-line);
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

textarea:focus {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

button {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 22px;
  margin-top: 14px;
  background: var(--navy);
  color: var(--paper);
  border: none;
  cursor: pointer;
}

button:hover:not(:disabled) { background: var(--amber-dark); }

button:disabled {
  background: #9AA5AE;
  cursor: not-allowed;
}

button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* Loading indicator */
#loading {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--moss);
}

.progress-track {
  width: 100%;
  background: var(--paper-line);
  height: 6px;
  margin-top: 6px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--amber);
  transition: width 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar { transition: none; }
}

/* Response output */
#responseLabel {
  margin-top: 28px;
  border-top: 1px dashed var(--paper-line);
  padding-top: 16px;
}

#response {
  white-space: pre-wrap;
  background: #fff;
  border: 1px solid var(--paper-line);
  padding: 16px;
  font-size: 0.95rem;
}

/* Log page */
.log-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--paper-line);
}

.log-date {
  font-size: 0.8rem;
  color: var(--moss);
  min-width: 90px;
  flex-shrink: 0;
}

footer {
  border-top: 2px solid var(--navy);
  padding: 20px 24px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--moss);
}

@media (max-width: 480px) {
  h1 { font-size: 1.7rem; }
  .header-inner { flex-direction: column; align-items: flex-start; }
}

/* Siege loading animation */
.siege-scene {
  position: relative;
  height: 110px;
  margin-top: 14px;
  overflow: hidden;
  background: linear-gradient(to bottom, #E3ECF0 0%, #E3ECF0 75%, #CBB98B 75%, #CBB98B 100%);
  border: 1px solid var(--paper-line);
}

.cannon {
  position: absolute;
  left: 10px;
  bottom: 12px;
  font-size: 1.6rem;
  transform: scaleX(1);
}

.cannonball {
  position: absolute;
  left: 40px;
  bottom: 26px;
  width: 10px;
  height: 10px;
  background: var(--ink);
  border-radius: 50%;
  opacity: 0;
}

.cannonball.firing {
  animation: fire 0.6s ease-out;
}

@keyframes fire {
  0%   { left: 40px; bottom: 26px; opacity: 1; }
  70%  { left: 240px; bottom: 40px; opacity: 1; }
  85%  { left: 240px; bottom: 40px; opacity: 1; }
  100% { left: 240px; bottom: 40px; opacity: 0; }
}






.castle {
  position: absolute;
  right: 20px;
  bottom: 12px;
  display: grid;
  grid-template-columns: repeat(4, 16px);
  grid-template-rows: repeat(5, 14px);
  gap: 2px;
}

.brick {
  background: var(--navy);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.brick.destroyed {
  opacity: 0;
  transform: scale(0.3) rotate(20deg);
}

.siege-status {
  font-size: 0.8rem;
  color: var(--moss);
  margin-top: 6px;
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .cannonball.firing { animation: none; opacity: 1; }
}
