/* Polk Seniors — senior-friendly, high-contrast, no ads */
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/AtkinsonHyperlegible-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/AtkinsonHyperlegible-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fff8f0;
  --bg-alt: #f3e6d6;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #334155;
  --header: #102a43;
  --header-text: #fffdf8;
  --primary: #0f4c5c;
  --primary-hover: #0a3843;
  --primary-text: #fffdf8;
  --accent: #8c2f1b;
  --accent-hover: #6e2414;
  --accent-text: #fffdf8;
  --link: #0a4a7a;
  --link-hover: #063156;
  --focus: #c47b00;
  --ok: #0b5f2a;
  --ok-bg: #e7f6ec;
  --emergency: #8b1e1e;
  --emergency-bg: #fdecec;
  --border: #d7c8b6;
  --shadow: 0 2px 0 rgba(16, 42, 67, 0.08), 0 8px 24px rgba(16, 42, 67, 0.08);
  --radius: 14px;
  --font: "Atkinson Hyperlegible", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --step: 22px;
  --line: 1.55;
  --max: 68rem;
}

html[data-size="s"] { --step: 18px; }
html[data-size="m"] { --step: 22px; }
html[data-size="l"] { --step: 26px; }
html[data-size="xl"] { --step: 30px; }

html {
  font-size: var(--step);
  background: var(--bg);
  color: var(--text);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  line-height: var(--line);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { color: var(--link-hover); }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 1000;
  background: var(--focus);
  color: #1a2332;
  font-weight: 700;
  padding: 0.6rem 1rem;
  border-radius: 0 0 10px 10px;
  text-decoration: none;
}
.skip:focus { top: 0; }

/* Header */
.site-header {
  background: var(--header);
  color: var(--header-text);
  box-shadow: 0 2px 0 rgba(0,0,0,0.15);
}
.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.7rem 1rem 0.85rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem 1rem;
  align-items: center;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--header-text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.15;
}
.logo img, .logo svg {
  width: 3.1rem;
  height: 3.1rem;
  flex: 0 0 3.1rem;
  border-radius: 0.7rem;
}
.logo small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.9;
}
.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}
.tool-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,253,248,0.25);
  border-radius: 999px;
  padding: 0.2rem 0.35rem 0.2rem 0.7rem;
}
.tool-group span {
  font-size: 0.8rem;
  margin-right: 0.2rem;
  white-space: nowrap;
}
.tool-group button, .tool-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--header-text);
  font: inherit;
  font-weight: 700;
  min-width: 2.4rem;
  min-height: 2.4rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
}
.tool-group button[aria-pressed="true"],
.tool-btn[aria-pressed="true"] {
  background: #fffdf8;
  color: #102a43;
}
.tool-group button:hover, .tool-btn:hover { background: rgba(255,253,248,0.2); }
.tool-group button[aria-pressed="true"]:hover { background: #fff; }
.menu-btn {
  display: none;
  appearance: none;
  border: 2px solid #fffdf8;
  background: transparent;
  color: #fffdf8;
  font: inherit;
  font-weight: 700;
  min-height: 2.8rem;
  padding: 0.35rem 0.9rem;
  border-radius: 10px;
  cursor: pointer;
  justify-self: end;
}
.menu-btn:hover { background: rgba(255,255,255,0.12); }

.site-nav {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.site-nav a {
  color: var(--header-text);
  text-decoration: none;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 2px solid transparent;
  min-height: 2.7rem;
  display: inline-flex;
  align-items: center;
}
.site-nav a:hover { background: rgba(255,255,255,0.12); }
.site-nav a[aria-current="page"] {
  background: #fffdf8;
  color: #102a43;
}
.site-nav a.nav-learn {
  background: #e8b84a;
  color: #1a2332;
  margin-left: auto;
}
.site-nav a.nav-learn:hover { background: #f3cc6a; color: #1a2332; }
.site-nav a.nav-emergency { border-color: #f3a3a3; }
.site-nav .ext-note {
  display: inline;
  font-size: 0.72em;
  font-weight: 400;
  margin-left: 0.4em;
  opacity: 0.9;
}

@media (max-width: 70rem) {
  .menu-btn { display: inline-flex; align-items: center; }
  .site-nav { display: none; }
  .site-nav.is-open {
    display: flex;
    flex-direction: column;
  }
  .site-nav a { width: 100%; }
  .site-nav a.nav-learn { margin-left: 0; }
  .header-inner { grid-template-columns: 1fr auto; }
}

/* Main */
.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  flex: 1;
}
h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 0.6rem;
}
h2 {
  font-size: 1.4rem;
  line-height: 1.25;
  margin: 1.6rem 0 0.6rem;
  color: var(--primary);
}
h3 { font-size: 1.15rem; margin: 1.1rem 0 0.4rem; }
p { margin: 0 0 0.85rem; }
.lead { font-size: 1.08rem; max-width: 42rem; }

.banner-learn {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  background: #fff3d6;
  border: 3px solid #c47b00;
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 0 0 1.4rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}
.banner-learn:hover { background: #ffe9b5; color: inherit; }
.banner-learn img {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: contain;
  flex: 0 0 4.5rem;
  background: #fff;
  border-radius: 10px;
  padding: 0.25rem;
}
.banner-learn strong { display: block; font-size: 1.2rem; color: var(--accent); }
.banner-learn span { color: var(--text); }

/* Cards / tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr));
  gap: 0.9rem;
  margin: 1rem 0 1.5rem;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  min-height: 8.5rem;
}
.tile:hover { border-color: var(--primary); color: inherit; }
.tile .icon { font-size: 1.8rem; line-height: 1; }
.tile h2, .tile h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--primary);
}
.tile p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.15rem;
  margin: 0 0 1rem;
  box-shadow: var(--shadow);
}
.card h2 { margin-top: 0; }
.list-links { list-style: none; margin: 0; padding: 0; }
.list-links li { margin: 0 0 0.75rem; }

/* Buttons */
.btn {
  appearance: none;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.1rem;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  border-radius: 12px;
  padding: 0.7rem 1.1rem;
  min-height: 3.3rem;
  border: 3px solid transparent;
  cursor: pointer;
  line-height: 1.25;
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
}
.btn-primary:hover { background: var(--primary-hover); color: var(--primary-text); }
.btn-accent {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-accent:hover { background: var(--accent-hover); color: var(--accent-text); }
.btn-ghost {
  background: var(--card);
  color: var(--text);
  border-color: var(--primary);
}
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }
.btn-emergency {
  background: var(--emergency);
  color: #fff;
  font-size: 1.25rem;
}
.btn-emergency:hover { background: #6d1515; color: #fff; }
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 0.7rem 0 1rem;
}
.ext-note, .tel-note {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  opacity: 0.92;
}
.btn .ext-note, .btn .tel-note { opacity: 0.85; }

.phone {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 2px solid var(--link);
}
.phone:hover { color: var(--link); }

.callout {
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  margin: 0 0 1.1rem;
  border: 3px solid;
}
.callout-ok { background: var(--ok-bg); border-color: var(--ok); }
.callout-warn { background: #fff3d6; border-color: #c47b00; }
.callout-emergency { background: var(--emergency-bg); border-color: var(--emergency); }
.callout h2 { margin-top: 0; }

.note {
  font-size: 0.95rem;
  color: var(--muted);
}

/* Footer */
.site-footer {
  background: var(--header);
  color: var(--header-text);
  padding: 1.4rem 1rem 2rem;
  margin-top: auto;
}
.site-footer .foot-inner { max-width: var(--max); margin: 0 auto; }
.site-footer a { color: #f3cc6a; }
.site-footer a:hover { color: #fff; }
.site-footer p { margin: 0 0 0.6rem; }
.foot-nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-bottom: 0.8rem; }

/* Games chrome */
.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
  align-items: center;
}
.game-toolbar button, .game-toolbar label {
  font: inherit;
  font-weight: 700;
}
.game-toolbar button {
  appearance: none;
  background: var(--primary);
  color: var(--primary-text);
  border: 0;
  border-radius: 10px;
  min-height: 2.8rem;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
}
.game-toolbar button:hover { background: var(--primary-hover); }
.game-toolbar button.secondary {
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--primary);
}
.game-toolbar select {
  font: inherit;
  min-height: 2.8rem;
  border-radius: 10px;
  border: 2px solid var(--primary);
  padding: 0.2rem 0.5rem;
  background: var(--card);
  color: var(--text);
}
.game-status {
  font-weight: 700;
  margin: 0 0 0.8rem;
  min-height: 1.5em;
}
.game-board-wrap { overflow-x: auto; padding-bottom: 0.5rem; }

/* Solitaire */
.solitaire {
  --card-w: clamp(3.4rem, 9vw, 4.6rem);
  --card-h: calc(var(--card-w) * 1.4);
  user-select: none;
}
.sol-row {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
  min-height: var(--card-h);
}
.sol-pile {
  width: var(--card-w);
  min-height: var(--card-h);
  position: relative;
  border-radius: 0.4rem;
  background: rgba(15, 76, 92, 0.12);
  border: 2px dashed var(--border);
}
.sol-pile.foundations { margin-left: auto; }
.sol-top { justify-content: flex-start; }
.sol-top .spacer { flex: 1; }
.tableau {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
}
.tab-col {
  width: var(--card-w);
  min-height: calc(var(--card-h) + 12 * 1.15rem);
  position: relative;
}
.s-card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 0.4rem;
  border: 2px solid #1a2332;
  background: #fff;
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font);
  font-weight: 700;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.12rem 0.18rem;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  color: #1a2332;
  line-height: 1;
  font-size: calc(var(--card-w) * 0.28);
}
.s-card.red { color: #a11616; }
.s-card.back {
  background: repeating-linear-gradient(45deg, #0f4c5c, #0f4c5c 6px, #163e54 6px, #163e54 12px);
  color: transparent;
  border-color: #0a3340;
}
.s-card.selected {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.s-card .corner { font-size: 0.85em; }
.s-card .suit { text-align: center; font-size: 1.35em; }
.sol-pile.empty-drop, .tab-col.empty-drop { background: rgba(196, 123, 0, 0.18); border-style: solid; border-color: var(--focus); }

/* Word search */
.ws-layout { display: grid; grid-template-columns: 1fr 14rem; gap: 1rem; align-items: start; }
@media (max-width: 50rem) { .ws-layout { grid-template-columns: 1fr; } }
.ws-grid {
  display: grid;
  gap: 3px;
  width: max-content;
  max-width: 100%;
}
.ws-cell {
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  text-transform: uppercase;
  padding: 0;
  font-family: inherit;
  color: var(--text);
}
.ws-cell.sel { background: #ffe9b5; border-color: #c47b00; }
.ws-cell.found { background: #c9ebd4; border-color: var(--ok); color: #0b5f2a; }
.ws-words { list-style: none; margin: 0; padding: 0; }
.ws-words li { padding: 0.25rem 0; }
.ws-words li.found { text-decoration: line-through; color: var(--ok); }

/* Sudoku */
.sudoku {
  display: grid;
  grid-template-columns: repeat(9, 2.5rem);
  width: max-content;
  border: 4px solid var(--text);
  margin: 0 auto 1rem;
}
.sud-cell {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid #8a7a68;
  text-align: center;
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  background: var(--card);
  color: var(--text);
  padding: 0;
  caret-color: var(--text);
}
.sud-cell:nth-child(9n+3),
.sud-cell:nth-child(9n+6) { border-right: 3px solid var(--text); }
.sud-cell:nth-child(n+19):nth-child(-n+27),
.sud-cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 3px solid var(--text); }
.sud-cell.given { background: var(--bg-alt); }
.sud-cell.hl { background: #fff3d6; }
.sud-cell.same { background: #e7f0f8; }
.sud-cell.error { background: #fdecec; color: var(--emergency); }
.sud-cell:focus { outline: 3px solid var(--focus); outline-offset: -3px; z-index: 1; }

/* Memory */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  max-width: 36rem;
}
.mem-card {
  appearance: none;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 3px solid var(--primary);
  background: var(--primary);
  color: var(--primary-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.3rem;
  min-height: 5.5rem;
}
.mem-card.face {
  background: var(--card);
  color: var(--text);
  flex-direction: column;
  gap: 0.15rem;
}
.mem-card.matched {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
  cursor: default;
}
.mem-card .sym { font-size: 1.8rem; line-height: 1; }
.mem-card .lab { font-size: 0.8rem; }

/* High contrast mode */
html.high-contrast {
  --bg: #000;
  --bg-alt: #111;
  --card: #000;
  --text: #fff;
  --muted: #fff;
  --header: #000;
  --header-text: #fff;
  --primary: #ffe600;
  --primary-hover: #fff27a;
  --primary-text: #000;
  --accent: #ffe600;
  --accent-hover: #fff27a;
  --accent-text: #000;
  --link: #7ec8ff;
  --link-hover: #fff;
  --focus: #00ffff;
  --ok: #5dff7a;
  --ok-bg: #000;
  --emergency: #ff6b6b;
  --emergency-bg: #000;
  --border: #fff;
  --shadow: none;
}
html.high-contrast .site-header,
html.high-contrast .site-footer { border-top: 4px solid #fff; border-bottom: 4px solid #fff; }
html.high-contrast .site-nav a[aria-current="page"],
html.high-contrast .tool-group button[aria-pressed="true"] {
  background: #ffe600;
  color: #000;
}
html.high-contrast .site-nav a.nav-learn { background: #ffe600; color: #000; }
html.high-contrast .banner-learn { background: #000; border-color: #ffe600; color: #fff; }
html.high-contrast .banner-learn strong { color: #ffe600; }
html.high-contrast .tile, html.high-contrast .card, html.high-contrast .btn-ghost {
  background: #000;
  color: #fff;
  border-color: #fff;
}
html.high-contrast .tile h2, html.high-contrast .tile h3, html.high-contrast h2 { color: #ffe600; }
html.high-contrast .s-card { border-color: #fff; }
html.high-contrast .s-card.red { color: #ff6b6b; background: #000; }
html.high-contrast .s-card:not(.red):not(.back) { background: #000; color: #fff; }
html.high-contrast .callout { background: #000; }
html.high-contrast .phone { color: #7ec8ff; border-bottom-color: #7ec8ff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
