/*
 * Optional low-vision presentation for CrossWordy.
 * Every rule is scoped so the standard display remains unchanged by default.
 */

html.accessible-mode {
  --blue: #0755c9;
  --blue-dark: #003f9e;
  --blue-soft: #dceaff;
  --green: #087a45;
  --red: #b4232d;
  --ink: #090a0c;
  --muted: #454a53;
  --line: #a9afb8;
  --key: #5b626d;
  --page: #f2f3f5;
}

html.accessible-mode body {
  background: var(--page);
}

html.accessible-mode button:focus-visible,
html.accessible-mode input:focus-visible,
html.accessible-mode a:focus-visible,
html.accessible-mode summary:focus-visible {
  outline: 4px solid #111;
  outline-offset: 3px;
  box-shadow: 0 0 0 7px #ffd43b;
}

html.accessible-mode .puzzle-identity {
  color: #424750;
  font-size: 14px;
  letter-spacing: .07em;
}

html.accessible-mode .puzzle-identity p:last-child {
  color: #171a1f;
}

html.accessible-mode .board-wrap {
  box-shadow: 0 0 0 2px #8b919b;
}

html.accessible-mode .cell {
  border-color: #9298a1;
  color: #090a0c;
  font-size: clamp(28px, 7.5vw, 42px);
}

html.accessible-mode .cell.blocked {
  border-color: #000;
  background: #090a0c;
}

html.accessible-mode .cell.selected {
  border-color: #0047ad;
  background: #dceaff;
  box-shadow: inset 0 0 0 2px #0047ad;
}

html.accessible-mode .cell.entry.wrong-entry {
  border-color: #8b0e1c;
  background: #fff;
  color: #090a0c;
  box-shadow: none;
}

html.accessible-mode .cell.direction-crossing::after {
  right: 2px;
  bottom: 2px;
  padding: 1px 2px;
  border-radius: 3px;
  background: #fff;
  color: #17191e;
  font-size: 13px;
}

html.accessible-mode .cell.discovered {
  border-color: #003b92;
  background: #0755c9;
  box-shadow: inset 0 0 0 2px #fff, 0 5px 12px rgba(0, 51, 128, .28);
}

html.accessible-mode .cell.solution {
  border-color: #737984;
  background: #d9dce1;
  color: #17191e;
}

html.accessible-mode .cell.solved {
  border-color: #08663d;
}

html.accessible-mode .selection-indicator {
  border-width: 2px;
  color: #003f9e;
  font-size: 16px;
}

html.accessible-mode .status {
  height: auto;
  min-height: 62px;
  color: #20242a;
  font-size: 17px;
  line-height: 1.4;
}

html.accessible-mode .status.error {
  color: #a3131f;
}

html.accessible-mode .hint-button {
  font-size: 16px;
}

html.accessible-mode .hint-button {
  border-width: 2px;
  border-color: #71809a;
}

html.accessible-mode .key {
  min-height: 54px;
  background: #5b626d;
  color: #fff;
  box-shadow: 0 3px 0 #30353d;
  font-size: 23px;
}

html.accessible-mode .key.used {
  background: #fff;
  color: #4b5058;
  box-shadow: inset 0 0 0 3px #747a84;
  text-decoration: line-through;
}

html.accessible-mode .key.current {
  background: #264e85;
  box-shadow: inset 0 0 0 3px #fff, 0 3px 0 #183457;
}

html.accessible-mode .key.jumbled {
  background: #ffe45c;
  color: #171300;
  box-shadow: inset 0 0 0 3px #685b00, 0 3px 0 #9f8900;
}

html.accessible-mode .key.tried:not(.used) {
  background: #fff0f1;
  color: #8b0e1c;
  box-shadow: inset 0 0 0 3px #a31323, 0 3px 0 #8b0e1c;
}

html.accessible-mode .key.delete-key {
  background: #d0d3d8;
  color: #17191e;
  box-shadow: inset 0 0 0 2px #626872, 0 3px 0 #626872;
}

html.accessible-mode .action-button {
  min-height: 60px;
  border-width: 2px;
  font-size: 20px;
}

html.accessible-mode dialog {
  color: #090a0c;
}

html.accessible-mode .dialog-copy {
  color: #363b43;
  font-size: 18px;
}

html.accessible-mode .eyebrow {
  color: #003f9e;
  font-size: 14px;
}

html.accessible-mode .menu-list button {
  min-height: 62px;
  border-color: #b6bbc3;
  color: #090a0c;
  font-size: 18px;
}

html.accessible-mode .menu-list small {
  color: #424750;
  font-size: 15px;
}

html.accessible-mode .accessibility-setting-copy strong {
  font-size: 18px;
}

html.accessible-mode .accessibility-setting-copy small,
html.accessible-mode .accessibility-note {
  color: #3f444c;
  font-size: 15px;
}

html.accessible-mode .toggle-track {
  box-shadow: inset 0 0 0 2px #777e88;
}

html.accessible-mode .accessibility-setting-input:focus-visible {
  outline: 0;
  box-shadow: none;
}

html.accessible-mode .accessibility-setting-input:focus-visible ~ .toggle-track {
  outline: 4px solid #111;
  outline-offset: 3px;
  box-shadow: 0 0 0 7px #ffd43b;
}

html.accessible-mode .pack-summary,
html.accessible-mode .difficulty-rules span,
html.accessible-mode .promo-code-panel p,
html.accessible-mode .result-progress {
  color: #424750;
  font-size: 18px;
}

html.accessible-mode .pack-tile h3,
html.accessible-mode .pack-card h3 {
  font-size: 18px;
}

html.accessible-mode .pack-theme-christmas.pack-tile,
html.accessible-mode .pack-theme-christmas.pack-card {
  border-width: 2px; border-color: #751721; box-shadow: inset 6px 0 0 #751721;
}
html.accessible-mode .pack-theme-christmas .pack-description { color: #30343a; font-size: 17px; }

html.accessible-mode body.game-theme-christmas .game-shell { border: 3px solid #751721; background: #fff; backdrop-filter: none; }
html.accessible-mode body.game-theme-christmas .cell:not(.blocked):not(.selected):not(.discovered):not(.solved):not(.solution) { background: #fffdf5; box-shadow: none; }

html.accessible-mode .difficulty-option {
  border-width: 2px;
  border-color: #9da4ae;
}

html.accessible-mode .difficulty-option.selected {
  border-color: #0047ad;
  box-shadow: 0 0 0 2px #0047ad;
}

html.accessible-mode .difficulty-rules {
  grid-template-columns: 1fr;
}

html.accessible-mode .difficulty-rules b {
  width: 36px;
  height: 36px;
  font-size: 22px;
}

html.accessible-mode .difficulty-rules span {
  grid-column: auto;
  grid-template-columns: 36px 1fr;
}

html.accessible-mode .help-start,
html.accessible-mode .help-feedback,
html.accessible-mode .help-finish {
  border-width: 2px;
  border-color: #8f969f;
}

html.accessible-mode .help-start strong,
html.accessible-mode .help-feedback strong,
html.accessible-mode .help-finish strong,
html.accessible-mode .help-section-title {
  font-size: 19px;
}

html.accessible-mode .help-start p,
html.accessible-mode .help-feedback p,
html.accessible-mode .help-finish p {
  color: #30353c;
  font-size: 17px;
}

html.accessible-mode .help-cell-wrong-entry {
  border-color: #8b0e1c;
  background: #fff;
  color: #090a0c;
  box-shadow: none;
}

@media (max-width: 560px) {
  html.accessible-mode .puzzle-identity {
    font-size: 12px;
  }

  html.accessible-mode .cell {
    font-size: clamp(24px, 8vw, 36px);
  }

  html.accessible-mode .selection-indicator,
  html.accessible-mode .hint-button {
    font-size: 15px;
  }

  html.accessible-mode .status {
    min-height: 64px;
    font-size: 16px;
  }

  html.accessible-mode .key {
    min-height: 52px;
    font-size: 21px;
  }

  html.accessible-mode .menu-list button {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

@media (max-width: 560px) and (max-height: 850px) {
  html.accessible-mode .game-shell {
    padding-top: 6px;
  }

  html.accessible-mode .board-wrap {
    width: min(100%, 340px);
  }

  html.accessible-mode .status {
    min-height: 58px;
  }

  html.accessible-mode .key {
    min-height: 46px;
  }
}

/* CrossWordy V210 native accessibility game fit START */

html.native-app.accessible-mode .game-shell {
  padding-top: calc(env(safe-area-inset-top) + 14px) !important;
}

@media (max-width: 560px) and (orientation: portrait) {
  html.native-app.accessible-mode .board-wrap,
  html.native-app.accessible-mode .game-shell:has(.assist-row[hidden]) .board-wrap {
    width: min(100%, 338px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 7px !important;
    box-sizing: border-box !important;
  }

  html.native-app.accessible-mode .board {
    gap: 5px !important;
  }

  html.native-app.accessible-mode .selection-indicator {
    margin-top: 7px !important;
    margin-bottom: 1px !important;
  }

  html.native-app.accessible-mode .status {
    height: 40px !important;
    min-height: 40px !important;
    margin: 0 auto 2px !important;
    line-height: 1.2 !important;
  }

  html.native-app.accessible-mode .assist-row {
    min-height: 32px !important;
    margin-bottom: 6px !important;
  }

  html.native-app.accessible-mode .keyboard {
    gap: 5px !important;
    margin-top: 0 !important;
    margin-bottom: 4px !important;
  }

  html.native-app.accessible-mode .keyboard-row {
    gap: 4px !important;
  }

  html.native-app.accessible-mode .key {
    height: 40px !important;
  }

  html.native-app.accessible-mode .actions {
    margin-top: 7px !important;
  }
}

/* CrossWordy V215: iPhone Air accessibility balance.
   Air-sized portrait viewports have enough width/height for a larger puzzle.
   Match the board more closely to keyboard width; the extra board height also
   moves the keyboard naturally downward without disturbing the bottom tray. */
@media (min-width: 410px) and (max-width: 430px) and (orientation: portrait) {
  html.native-app.accessible-mode .board-wrap,
  html.native-app.accessible-mode .game-shell:has(.assist-row[hidden]) .board-wrap {
    width: min(calc(100% - 8px), 382px) !important;
  }
}

/* CrossWordy V218: iPhone 17 Pro Max accessibility spacing.
   Keep Remove Ads and the large board high, but explicitly cancel the older
   Pro Max keyboard/hint lifts so the status, hint and keyboard stack naturally. */
@media (min-width: 431px) and (max-width: 560px) and (orientation: portrait) {
  html.native-app.accessible-mode .puzzle-identity {
    margin-top: 2px !important;
    margin-bottom: 6px !important;
    transform: translateY(-10px) !important;
  }

  html.native-app.accessible-mode .board-wrap,
  html.native-app.accessible-mode .game-shell:has(.assist-row[hidden]) .board-wrap {
    width: min(calc(100% - 10px), 410px) !important;
    transform: translateY(-10px) !important;
  }

  html.native-app.accessible-mode .selection-indicator {
    margin-top: 4px !important;
    margin-bottom: 1px !important;
  }

  html.native-app.accessible-mode .status {
    height: 38px !important;
    min-height: 38px !important;
    margin: 0 auto 5px !important;
  }

  /* V178 lifts .assist-row by 10px on wide iPhones. Accessibility mode must
     cancel that or the hint pill rides over the status text. */
  html.native-app.accessible-mode .assist-row {
    transform: none !important;
    min-height: 34px !important;
    margin-top: 4px !important;
    margin-bottom: 10px !important;
  }

  /* V177 uses margin-top:-18px on the Pro Max keyboard. Cancel that in
     accessibility mode so the keyboard sits lower and keeps clear of the hint. */
  html.native-app.accessible-mode .keyboard {
    transform: none !important;
    margin-top: 6px !important;
    margin-bottom: 4px !important;
  }
}

html.native-app.accessible-mode .cell.discovered,
html.native-app.accessible-mode .cell.entry.discovered,
html.native-app.accessible-mode .cell.selected.discovered {
  color: #fff !important;
}

/* CrossWordy V210 native accessibility game fit END */

/* CrossWordy V222 short-screen accessibility rules START */
@media (max-width: 430px) and (max-height: 720px) and (orientation: portrait) {
  html.accessible-mode .game-shell {
    height: 100dvh !important;
    min-height: 100dvh !important;
    padding: max(4px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  html.accessible-mode .puzzle-identity {
    height: 18px !important;
    min-height: 18px !important;
    margin: 0 0 10px !important;
    transform: none !important;
  }
  html.accessible-mode .board-wrap,
  html.accessible-mode .game-shell:has(.assist-row[hidden]) .board-wrap {
    width: min(calc(100vw - 20px), calc(100dvh - 405px)) !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: none !important;
    aspect-ratio: 1 / 1 !important;
    margin: 0 auto 8px !important;
    padding: 6px !important;
    transform: none !important;
  }
  html.accessible-mode .selection-indicator { margin: 0 auto 4px !important; }
  html.accessible-mode .status-assist-zone {
    height: 50px !important;
    min-height: 50px !important;
    margin: 0 0 10px !important;
  }
  html.accessible-mode .status-assist-zone .status {
    height: 48px !important;
    min-height: 48px !important;
    margin: 0 !important;
    font-size: 11px !important;
    line-height: 15px !important;
  }
  html.accessible-mode .status-assist-zone .assist-row {
    height: 38px !important;
    min-height: 38px !important;
    margin: 0 !important;
    transform: none !important;
  }
  html.accessible-mode .controls { margin: 0 !important; padding: 0 !important; }
  html.accessible-mode .keyboard {
    margin: 0 0 10px !important;
    transform: none !important;
    gap: 6px !important;
  }
  html.accessible-mode .key { height: 44px !important; min-height: 44px !important; }
  html.accessible-mode .actions {
    position: static !important;
    inset: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  html.accessible-mode .action-button { height: 52px !important; min-height: 52px !important; }
}
/* CrossWordy V222 short-screen accessibility rules END */

/* CrossWordy V223 short-screen accessibility rules START */
@media (max-width: 430px) and (max-height: 720px) and (orientation: portrait) {
  html.accessible-mode .game-shell {
    height: 100dvh !important;
    min-height: 100dvh !important;
    padding: max(4px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  html.accessible-mode .puzzle-identity {
    height: 18px !important;
    min-height: 18px !important;
    margin: 0 0 10px !important;
    transform: none !important;
  }
  html.accessible-mode .puzzle-identity { display: flex !important; align-items: center !important; justify-content: center !important; width: 100% !important; text-align: center !important; }
  html.accessible-mode .remove-ads-header-link { display: block !important; margin: 0 auto !important; text-align: center !important; }
  html.accessible-mode .board-wrap,
  html.accessible-mode .game-shell:has(.assist-row[hidden]) .board-wrap {
    width: min(calc(100vw - 32px), 292px, calc(100dvh - 440px)) !important;
    max-width: 292px !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: none !important;
    aspect-ratio: 1 / 1 !important;
    margin: 0 auto 8px !important;
    padding: 6px !important;
    transform: none !important;
  }
  html.accessible-mode .selection-indicator { margin: 0 auto 4px !important; }
  html.accessible-mode .status-assist-zone {
    height: 50px !important;
    min-height: 50px !important;
    margin: 0 0 10px !important;
  }
  html.accessible-mode .status-assist-zone .status {
    height: 48px !important;
    min-height: 48px !important;
    margin: 0 !important;
    font-size: 11px !important;
    line-height: 15px !important;
  }
  html.accessible-mode .status-assist-zone .assist-row {
    height: 38px !important;
    min-height: 38px !important;
    margin: 0 !important;
    transform: none !important;
  }
  html.accessible-mode .controls { margin: 0 !important; padding: 0 !important; }
  html.accessible-mode .keyboard {
    margin: 0 0 10px !important;
    transform: none !important;
    gap: 6px !important;
  }
  html.accessible-mode .key { height: 36px !important; min-height: 36px !important; font-size: 16px !important; }
  html.accessible-mode .actions {
    position: static !important;
    inset: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  html.accessible-mode .action-button { height: 52px !important; min-height: 52px !important; }
}
/* CrossWordy V223 short-screen accessibility rules END */

/* CrossWordy V295: keep the illustrated Game Menu structure in Accessible display. */
html.accessible-mode #menu-dialog .menu-list .menu-item {
  display: grid;
  align-items: center;
}
html.accessible-mode #menu-dialog .menu-item-title {
  color: #090a0c;
  font-size: 18px;
}
html.accessible-mode #menu-dialog .menu-item-chevron {
  color: #424750;
}
@media (max-width: 560px) {
  html.accessible-mode #menu-dialog .menu-list .menu-item {
    grid-template-columns: 48px minmax(0, 1fr) 18px;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 3px 12px;
  }
  html.accessible-mode #menu-dialog .menu-item-icon {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 46px;
    height: 46px;
  }
  html.accessible-mode #menu-dialog .menu-item-title {
    grid-column: 2;
    grid-row: 1;
  }
  html.accessible-mode #menu-dialog .menu-list .menu-item small {
    grid-column: 2;
    grid-row: 2;
    text-align: left;
  }
  html.accessible-mode #menu-dialog .menu-item-chevron {
    grid-column: 3;
    grid-row: 1 / span 2;
  }
}
