/* Hexadoku.de - Pure, minimalist print/newspaper aesthetic */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --ink: #111111;
  --ink-muted: #555555;
  --border-light: #cccccc;
  --border-dark: #111111;
  --highlight-cross: #f3f0ea;
  --highlight-match: #e9e5dc;
  --highlight-selected: #fef08a;
  --user-val: #0f3ba2;
  --error: #b91c1c;
  --error-bg: #fee2e2;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: Georgia, "Times New Roman", Times, serif;
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.site-header {
  border-bottom: 2px solid var(--border-dark);
  padding: 0.75rem 1rem 0.5rem;
  background: var(--surface);
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand {
  text-decoration: none;
  color: var(--ink);
}

.brand h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline;
}

.brand span {
  font-size: 0.85rem;
  color: var(--ink-muted);
  font-style: italic;
  margin-left: 0.5rem;
}

.header-status {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timer {
  font-family: "Courier New", Courier, monospace;
  font-weight: bold;
  border: 1px solid var(--border-dark);
  padding: 0.1rem 0.4rem;
  background: var(--bg);
}

/* Main */
.main-content {
  flex: 1;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

/* Controls */
.controls-bar {
  width: 100%;
  max-width: 640px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.btn-group {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-dark);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn:hover {
  background: var(--bg);
}

.btn.active {
  background: var(--border-dark);
  color: var(--surface);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

select.btn {
  padding-right: 0.2rem;
}

/* Status Bar */
.status-bar {
  width: 100%;
  max-width: 620px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.82rem;
  padding: 0.35rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  color: var(--ink);
  min-height: 1.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  transition: all 0.15s ease;
}

.status-bar.success {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
  font-weight: 600;
}

.status-bar.warning {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
  font-weight: 600;
}

.status-bar.info {
  background: var(--surface);
  border-color: var(--border-light);
  color: var(--ink);
}

/* Board Grid */
.board-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
}

.grid-16x16 {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  grid-template-rows: repeat(16, minmax(0, 1fr));
  width: min(92vw, 620px, 66vh);
  height: min(92vw, 620px, 66vh);
  background-color: var(--surface);
  border: 2.5px solid var(--border-dark);
  user-select: none;
  touch-action: manipulation;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.72rem, 2.5vw, 1.25rem);
  font-weight: bold;
  cursor: pointer;
  background-color: var(--surface);
}

/* 4x4 subgrid divisions */
.cell:nth-child(4n) {
  border-right: 2px solid var(--border-dark);
}
.cell:nth-child(16n) {
  border-right: none;
}

.cell[data-row="3"],
.cell[data-row="7"],
.cell[data-row="11"] {
  border-bottom: 2px solid var(--border-dark);
}
.cell[data-row="15"] {
  border-bottom: none;
}

/* Cell values */
.cell.clue {
  color: var(--ink);
  font-weight: 900;
}

.cell.user-value {
  color: var(--user-val);
  font-style: italic;
}

.cell.highlight-cross {
  background-color: var(--highlight-cross);
}

.cell.highlight-match {
  background-color: var(--highlight-match);
}

.cell.selected {
  background-color: var(--highlight-selected) !important;
  outline: 2px solid var(--border-dark);
  outline-offset: -2px;
  z-index: 2;
}

.cell.error {
  background-color: var(--error-bg) !important;
  color: var(--error) !important;
}

/* Notes */
.notes-grid {
  position: absolute;
  inset: 1px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  pointer-events: none;
}

.note-item {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.35rem, 0.75vw, 0.52rem);
  font-family: "Courier New", Courier, monospace;
  color: var(--ink-muted);
  line-height: 1;
}

/* Keypad */
.keypad-wrapper {
  width: 100%;
  max-width: 620px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.keypad-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.25rem;
}

.key-btn {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-dark);
  padding: 0.35rem 0.1rem 0.25rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  min-height: 2.6rem;
  transition: all 0.08s ease;
}

.key-char {
  font-family: "Courier New", Courier, monospace;
  font-size: 1.05rem;
  font-weight: bold;
  line-height: 1;
}

.key-count {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.62rem;
  color: var(--ink-muted);
  line-height: 1;
  margin-top: 2px;
}

.key-btn.completed {
  opacity: 0.45;
  background: var(--bg);
}

.key-btn.completed .key-count {
  color: #166534;
  font-weight: bold;
}

.key-btn.active {
  outline: 2px solid var(--ink);
  outline-offset: -1px;
  background: var(--highlight-selected);
}

.key-btn:active {
  background: var(--highlight-selected);
}

/* Actions */
.actions-bar {
  width: 100%;
  max-width: 620px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-dark);
  padding: 1rem 0.5rem;
  font-size: 0.8rem;
  text-align: center;
  background: var(--surface);
}

.footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.4rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.footer-nav a, .footer-nav button {
  color: var(--ink);
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
}

.footer-copy {
  color: var(--ink-muted);
  font-size: 0.76rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--surface);
  border: 2px solid var(--border-dark);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-dark);
  padding-bottom: 0.35rem;
}

.modal-header h2 {
  font-size: 1.25rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-body h3 {
  font-size: 1rem;
  margin: 0.75rem 0 0.25rem;
}

.modal-body p { margin-bottom: 0.5rem; }
.modal-body ul { padding-left: 1.25rem; margin-bottom: 0.5rem; }
.modal-body li { margin-bottom: 0.2rem; }

/* Archive Table */
.archive-container {
  width: 100%;
  max-width: 800px;
}

.archive-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.archive-search {
  flex: 1;
  min-width: 200px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border-dark);
  font-family: inherit;
  font-size: 0.85rem;
}

.archive-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border-dark);
  font-size: 0.85rem;
}

.archive-table th, .archive-table td {
  padding: 0.45rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.archive-table th {
  background: var(--bg);
  border-bottom: 1px solid var(--border-dark);
}

.badge-status {
  display: inline-block;
  font-size: 0.68rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
  font-weight: 600;
  margin-left: 0.4rem;
  vertical-align: middle;
  line-height: 1.2;
}

.badge-solved {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #86efac;
}

.badge-progress {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.archive-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.82rem;
}

/* Puzzle Guide Section */
.puzzle-guide {
  width: 100%;
  max-width: 620px;
  margin-top: 1.25rem;
  border-top: 1px solid var(--border-dark);
  padding-top: 1rem;
  font-size: 0.88rem;
  line-height: 1.55;
}

.puzzle-guide h2 {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
  font-weight: bold;
}

.puzzle-guide h3 {
  font-size: 0.95rem;
  margin: 0.75rem 0 0.25rem;
  font-weight: bold;
}

.puzzle-guide p {
  margin-bottom: 0.6rem;
}

.puzzle-guide ul {
  padding-left: 1.2rem;
  margin-bottom: 0.6rem;
}

.puzzle-guide li {
  margin-bottom: 0.2rem;
}

.puzzle-guide code {
  font-family: "Courier New", Courier, monospace;
  font-weight: bold;
  background: var(--surface);
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--border-light);
  font-size: 0.82rem;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 0.75rem 0;
}

@media (min-width: 640px) {
  .guide-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Anniversary Banner & Promotion */
.anniversary-banner {
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border: 1.5px solid var(--border-dark);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.08);
}

.anniversary-banner-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.anniversary-badge {
  display: inline-block;
  align-self: flex-start;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
}

.anniversary-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--ink);
}

.anniversary-desc {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.btn-anniversary {
  white-space: nowrap;
  font-weight: 600;
  border: 1.5px solid var(--ink);
  background: var(--surface);
  box-shadow: 2px 2px 0px #000;
}
.btn-anniversary:hover {
  background: var(--ink);
  color: var(--surface);
}

/* Anniversary Feature Box in Guide */
.anniversary-feature-box {
  border: 1.5px solid var(--border-dark);
  background: var(--surface);
  padding: 1rem;
  margin: 1.2rem 0;
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.anniversary-cover-img {
  width: 110px;
  height: auto;
  border: 1px solid var(--border-dark);
  box-shadow: 3px 3px 0px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.anniversary-feature-text {
  flex: 1;
}

.anniversary-feature-text h3 {
  font-size: 1.15rem;
  margin: 0.25rem 0 0.4rem 0;
  border: none;
  padding: 0;
}

/* Archive Callout */
.archive-anniversary-callout {
  background: var(--surface);
  border: 1.5px solid var(--border-dark);
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.88rem;
}

@media (max-width: 600px) {
  .anniversary-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .anniversary-feature-box {
    flex-direction: column;
    align-items: center;
    text-align: left;
  }
  .anniversary-cover-img {
    width: 120px;
  }
  .archive-anniversary-callout {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Print */
@media print {
  body {
    background: #ffffff !important;
  }
  .site-header,
  .controls-bar,
  .keypad-wrapper,
  .actions-bar,
  .site-footer,
  .modal-overlay,
  .puzzle-guide,
  .status-bar,
  .anniversary-banner,
  .anniversary-feature-box,
  .archive-anniversary-callout {
    display: none !important;
  }
  .print-only-header {
    display: block !important;
    text-align: center;
    margin-bottom: 1.2rem;
    border-bottom: 1px solid #000;
    padding-bottom: 0.3rem;
  }
  .grid-16x16 {
    width: 170mm !important;
    height: 170mm !important;
    border: 3px solid #000000 !important;
    margin: 0 auto;
  }
  .cell {
    border-right: 1px solid #555555 !important;
    border-bottom: 1px solid #555555 !important;
  }
  .cell:nth-child(4n) {
    border-right: 2.5px solid #000000 !important;
  }
  .cell:nth-child(16n) {
    border-right: none !important;
  }
  .cell[data-row="3"],
  .cell[data-row="7"],
  .cell[data-row="11"] {
    border-bottom: 2.5px solid #000000 !important;
  }
  .notes-grid {
    display: none !important;
  }
}

.print-only-header {
  display: none;
}
