/*!* Registering this as a <length-percentage> lets the browser smoothly*/
/*   interpolate it (and, transitively, the gradient built from it below)*/
/*   instead of snapping to the new value the instant the card's height*/
/*   changes (e.g. a new history row appearing after a guess/hint). *!*/
/*@property --bg-fade-start {*/
/*  syntax: "<length-percentage>";*/
/*  inherits: true;*/
/*  initial-value: 50%;*/
/*}*/

/* These files are served by Exaqtly, so visitors do not need either font
   installed locally and the design does not rely on Google Fonts access. */
@font-face {
  font-family: "Ubuntu Mono Bold";
  src: url("fonts/Ubuntu-Mono-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Light";
  src: url("fonts/IBMPlexSans-Light.ttf") format("truetype");
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Regular";
  src: url("fonts/IBMPlexSans-Regular.ttf") format("truetype");
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Medium";
  src: url("fonts/IBMPlexSans-Medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Medium";
  src: url("fonts/IBMPlexSans-Medium.ttf") format("truetype");
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Bold";
  src: url("fonts/IBMPlexSans-Bold.ttf") format("truetype");
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6f5f1;
  --card-bg: #dddddd;
  --ink: #363333;
  --muted: #787c7e;
  --border: #d3d6da;

  /* --accent / --logo-accent are set per-season below (see the
     html.season-* rules) based on today's date, computed server-side in
     app.py's current_season(). These are just a fallback in case that
     class is ever missing. */
  --accent: #5d6442;
  --logo-accent: #b6c18b;

  --correct: #538d4e;
  --wrong: #b0413e;
  --dot-empty: #e3e3e3;
  --dot-used: var(--ink);

  /* Background image fade: the % of the image's height (from its top) at
     which it becomes fully opaque. Lower = shorter/sharper fade, higher =
     longer/softer. See .bg-fade for the full explanation. */
  --bg-fade-solid-at: 75%;
}

html.season-winter {
  --accent: #424d64;
  --logo-accent: #96a9d1;
}

html.season-spring {
  --accent: #426459;
  --logo-accent: #7db6a3;
}

html.season-summer {
  --accent: #5d6442;
  --logo-accent: #b6c18b;
}

html.season-autumn {
  --accent: #645142;
  --logo-accent: #bc9b81;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "IBM Plex Sans Regular", Helvetica, Arial, sans-serif;
}

body {
  position: relative;
  background-color: var(--bg);
}

.bg-fade {
  /* Swap static/background.png for a different image any time - same
     filename, no other changes needed. The flat accent-color layer is
     blended over the photo (blend mode "color") to tint it, keeping the
     photo's original luminance/detail but recoloring it to match --accent.

     This box is sized to the image's OWN aspect ratio and pinned to the
     bottom of the page, so it is exactly as tall as the fully-visible
     image on any screen. The fade below is then a simple percentage of
     this box - it always begins at the image's own top edge and ramps
     down over it, so there is never a hard seam regardless of screen
     shape. --bg-image-aspect (width/height) is set from the real image by
     main.js; the literal here is a fallback for the current image. */
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  aspect-ratio: var(--bg-image-aspect, 1983 / 793);
  pointer-events: none;
  background-image: linear-gradient(var(--accent), var(--accent)), url("background.png");
  background-size: 100% 100%, 100% 100%;
  background-repeat: no-repeat, no-repeat;
  background-blend-mode: color;
  /* THE ONE KNOB: where the image reaches full opacity, as a % of its own
     height from the top. Smaller % = image appears sooner (sharper edge).
     Larger % = longer, softer fade. 100% would fade across the whole
     image. Tune --bg-fade-solid-at to taste. */
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    black var(--bg-fade-solid-at, 75%)
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    black var(--bg-fade-solid-at, 75%)
  );
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 48px;
}

body.keyboard-open .page {
  padding: 12px 16px 12px;
}

body.keyboard-open .header,
body.keyboard-open .menu-btn {
  display: none;
}

body.keyboard-open .card {
  padding: 16px 18px;
}

body.keyboard-open .attempts {
  margin-bottom: 12px;
}

body.keyboard-open .quote-wrap {
  margin: 20px 0 16px;
}

body.keyboard-open .author {
  margin: 0 0 12px;
}

body.keyboard-open .guess-form {
  margin-bottom: 0;
}

body.keyboard-open .secondary-actions {
  margin-top: 10px;
}

.top-bar {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

.menu-btn {
  position: absolute;
  top: 0;
  left: 16px;
  z-index: 30;
  width: 40px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  cursor: pointer;
}

.menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 20;
}

.menu-overlay.visible {
  display: block;
}

.menu-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 25;
  width: 260px;
  max-width: 80vw;
  background: var(--card-bg);
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.15);
  padding: 72px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.menu-panel.visible {
  transform: translateX(0);
}

.menu-auth {
  font-size: 1.1rem;
  color: var(--muted);
  padding: 8px 10px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 10px;
  border-radius: 8px;
}

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

.auth-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.auth-link:hover {
  opacity: 0.7;
}

.header {
  text-align: center;
  transform: translateY(-18px);
  margin-bottom: 24px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.0);
  border-radius: 18px;
  backdrop-filter: blur(6px);
}

.header h1 {
  display: flex;
  justify-content: center;
  font-size: 3.3rem;
  letter-spacing: 0.05em;
  margin: 0;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
  font-family: "Ubuntu Mono Bold";
}

.header h1 .logo-q {
  color: var(--ink) !important;
}

.header h1 .logo-accent-letter {
  color: var(--logo-accent) !important;
}

.logo-accent-letter {
  color: var(--logo-accent);
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-family: "IBM Plex Sans Light", Helvetica, Arial, sans-serif;
  font-weight: 300;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card {
  position: relative;
  margin-top: -28px;
  background: color-mix(in srgb, var(--card-bg) 0%, transparent);
  backdrop-filter: blur(6px);
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
  padding: 17px 30px 30px;
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.puzzle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 680px;
  min-height: 24px;
  margin-bottom: 12px;
}

.puzzle-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
  transform: translateX(-18px);
}

.puzzle-bar-actions {
  display: flex;
  gap: 12px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
}

.link-btn:hover {
  opacity: 0.7;
}

.link-btn.hidden {
  display: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  text-decoration: none;
  padding: 0;
}

.attempts {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--dot-empty);
  border: 2px solid rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.dot.used {
  background: var(--dot-used);
  border-color: var(--dot-used);
  transform: scale(1.15);
}

.quote-wrap {
  position: relative;
  width: 100%;
  max-width: 680px;
  margin: 28px 0 26px;
  display: flex;
  justify-content: center;
  min-height: 1.5em;
}

.quote-wrap::before,
.quote-wrap::after {
  font-family: Georgia, "Times New Roman", serif;
  font-style: normal;
  font-weight: 700;
  font-size: 5.1rem;
  line-height: 1;
  color: var(--accent);
  opacity: 0.12;
  pointer-events: none;
  user-select: none;
}

.quote-wrap::before {
  content: "\201C";
  position: absolute;
  top: -38px;
  left: -18px;
}

.quote-wrap::after {
  content: "\201D";
  position: absolute;
  bottom: -68px;
  right: -18px;
}

#quote-canvas {
  display: block;
  max-width: 100%;
}

.author {
  margin: 0 0 16px;
  color: var(--muted);
  font-weight: 600;
  font-size: 1.1rem;
}

.answer-stack {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
}

.guess-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.guess-form input {
  width: 100%;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.guess-form input:focus {
  border-color: var(--accent);
}

.guess-form input:disabled,
.guess-form input:read-only {
  background: #f0f0f0;
  color: var(--muted);
}

.primary-btn {
  width: 100%;
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.primary-btn:hover:not(:disabled) {
  background: #363333;
}

.primary-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.primary-btn:disabled {
  background: var(--dot-empty);
  cursor: not-allowed;
}

.primary-btn.hidden {
  display: none;
}

.stack-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 12px 0;
}

.stack-divider .divider-line {
  flex: 1;
  height: 3px;
  background: var(--border);
}

.stack-divider .divider-label {
  font-size: 1.05rem;
  font-weight: normal;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.secondary-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.next-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.next-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

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

.next-btn.hidden {
  display: none;
}

/* Hide the legacy control on older cached page templates as well. */
#next-quote-btn {
  display: none !important;
}

.history {
  width: 100%;
  max-width: 480px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-entry {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 1rem;
  background: #f6f5f1;
  border: 1px solid var(--border);
}

.history-entry.incorrect {
  color: var(--muted);
  border-color: var(--border);
}

.history-entry.correct {
  color: var(--correct);
  border-color: rgba(83, 141, 78, 0.35);
}

.history-entry.invalid {
  color: var(--muted);
  border-style: dashed;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  padding: 16px;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 36px 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  transform: translateY(12px);
  transition: transform 0.25s ease;
}

.modal-overlay.visible .modal {
  transform: translateY(0);
}

.modal h2 {
  margin: 0 0 32px;
  font-size: 1.9rem;
}

.modal-quote {
  margin: 0 0 12px;
  padding: 0;
  border: none;
  font-family: "Courier New", monospace;
  font-style: italic;
  font-size: 1.25rem;
  line-height: 1.6;
  color: var(--ink);
}

.modal-author {
  margin: 0 0 24px;
  color: var(--muted);
  font-weight: 600;
}

.modal-context {
  margin: -8px 0 24px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
  text-align: left;
}

.modal-context.hidden {
  display: none;
}

.modal button:not(.archive-cell) {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.modal button:not(.archive-cell):hover {
  background: #000;
}

#play-again.hidden {
  display: none;
}

.giveup-text {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.invalid-guess-modal {
  max-width: 360px;
}

.invalid-guess-text {
  margin: 0 0 20px;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions button {
  flex: 1;
}

.modal-btn-secondary {
  padding: 12px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.modal-btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.modal-btn-danger {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  background: var(--wrong);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.modal-btn-danger:hover {
  background: #8a3230;
}

.archive-modal {
  max-width: 420px;
  text-align: left;
}

.archive-modal h2 {
  text-align: center;
}

.archive-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.archive-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.archive-month-label {
  font-weight: 600;
  font-size: 1rem;
  text-align: center;
  flex: 1;
}

.archive-month-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.archive-month-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.archive-month-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.archive-calendar {
  max-height: 400px;
  overflow-x: hidden;
  overflow-y: auto;
  margin-bottom: 20px;
}

.archive-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.archive-weekdays span {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.archive-cell-empty {
  visibility: hidden;
}

.archive-cell {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  position: relative;
  min-width: 0;
  margin: 0;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.1s ease, background-color 0.2s ease;
}

.archive-cell:hover:not(:disabled) {
  border-color: var(--accent);
  transform: scale(1.05);
}

.archive-cell:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.archive-cell-icon {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.7rem;
  line-height: 1;
}

.archive-cell-won {
  background: rgba(83, 141, 78, 0.15);
  border-color: transparent;
  color: var(--correct);
}

.archive-cell-lost {
  background: rgba(176, 65, 62, 0.12);
  border-color: transparent;
  color: var(--wrong);
}

.archive-cell-playing {
  background: rgba(18, 18, 19, 0.08);
  border-color: var(--accent);
  color: var(--accent);
}

.archive-cell-not_started {
  background: var(--bg);
  color: var(--muted);
}

.archive-cell-today {
  border-color: var(--accent);
  border-width: 2px;
  font-weight: 700;
  color: var(--accent);
}

.archive-empty {
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
  padding: 12px 0;
}

#archive-close {
  width: 100%;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}

#archive-close:hover {
  background: var(--bg);
}

.howto-modal {
  max-width: 460px;
  text-align: left;
}

.howto-modal h2 {
  text-align: center;
}

.howto-list {
  margin: 0 0 22px;
  padding-left: 20px;
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.howto-list li {
  padding-left: 2px;
}

.howto-correct {
  color: var(--correct);
  font-weight: 700;
}

#howto-close {
  width: 100%;
}

.auth-modal {
  max-width: 380px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.auth-input {
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.auth-input:focus {
  border-color: var(--accent);
}

.auth-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--wrong);
  font-size: 0.95rem;
}

#auth-submit {
  width: 100%;
}

.auth-toggle {
  margin: 10px 0 20px;
  font-size: 0.95rem;
}

.auth-toggle a {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

#auth-close {
  width: 100%;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}

#auth-close:hover {
  background: var(--bg);
}

@media (max-width: 480px) {
  .card {
    padding: 26px 18px 20px;
  }

  .attempts {
    gap: 8px;
  }

  .dot {
    width: 20px;
    height: 20px;
  }
}
