/* Klok kijken: home tile, round menu, the question screen (prompt, clock, controls, progress),
   and the digital rounds (the digital clock, the day strip, the steppers).
   Shared look lives in css/style.css. */

/* ---------- home tile ---------- */
#tile-klok .tile-art { display: flex; align-items: center; justify-content: center; }
#tile-klok .klok-svg { width: 92px; height: 92px; display: block; }

/* ---------- menu ----------
   The shell's menu components (css/style.css, js/menu.js): mode cards, then level cells per tier. */

/* ---------- the question screen ---------- */
.klok-hud { gap: 10px; }
#klok-hint svg { width: 30px; height: 30px; fill: var(--gold); stroke: var(--primary-dark); stroke-width: 1.2; }
#klok-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 2px 12px 12px;
}

/* the task */
.klok-prompt {
  width: min(100%, 520px);
  min-height: 70px;
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 10px;
  padding: 8px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 #d6cff7;
  text-align: center;
}
.klok-lead { width: 100%; font-size: 0.95rem; font-weight: 800; color: var(--ink-soft); }
.klok-target { font-size: clamp(1.3rem, 6vw, 1.75rem); font-weight: 900; color: var(--primary); line-height: 1.15; overflow-wrap: break-word; hyphens: auto; }
.klok-target.digits, .klok-option.digits { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.klok-target.digits { font-size: clamp(1.8rem, 9vw, 2.4rem); }
.klok-digital {
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 1.1rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* the clock */
.klok-face {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.klok-face.activity .klok-activity { width: auto; height: 100%; max-height: 230px; max-width: 100%; aspect-ratio: 80 / 72; display: block; padding: 14px; border-radius: 28px; background: rgba(255, 255, 255, 0.9); box-shadow: 0 5px 0 #d6cff7; }
.klok-target.small { font-size: clamp(1.05rem, 4.6vw, 1.3rem); }
.klok-face .klok-svg { height: 100%; max-height: 380px; width: auto; max-width: 100%; aspect-ratio: 220 / 238; display: block; overflow: visible; }
.klok-face.interactive { touch-action: none; cursor: grab; }
.klok-face.interactive:active { cursor: grabbing; }
.klok-hand.grabbed path:last-child { filter: drop-shadow(0 0 4px rgba(255, 197, 49, 0.95)); }
.klok-hand.hint, .klok-daypart.hint { animation: klok-pulse 0.75s ease-in-out infinite alternate; }
@keyframes klok-pulse {
  from { filter: drop-shadow(0 0 0 rgba(255, 197, 49, 0)); }
  to { filter: drop-shadow(0 0 7px rgba(255, 170, 0, 1)); }
}
.klok-face.happy .klok-svg { animation: klok-hop 0.5s ease-out; }
@keyframes klok-hop {
  0% { transform: scale(1); }
  40% { transform: scale(1.05) rotate(-2deg); }
  100% { transform: scale(1); }
}

/* controls, progress and status */
.klok-side { width: min(100%, 520px); flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.klok-controls { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.klok-nudges { width: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 18px; }
.klok-nudge { display: flex; align-items: center; gap: 8px; }
.klok-nudge-name { min-width: 0; flex: 0 1 auto; white-space: nowrap; text-align: center; font-size: 0.95rem; font-weight: 900; line-height: 1.1; }
.klok-nudge.hour .klok-nudge-name { color: #e2581f; }
.klok-nudge.minute .klok-nudge-name { color: #2563eb; }
.klok-btn.round {
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  font: 900 1.7rem/1 var(--font);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(43, 35, 112, 0.35);
}
.klok-btn.round.hour { background: #ff7a3d; color: var(--bz-on-accent); } /* ink on orange 5.1:1; white was 2.6:1 */
.klok-btn.round.minute { background: #3b82f6; }
.klok-btn.round:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(43, 35, 112, 0.35); }
.klok-btn.round:focus-visible { outline: 4px solid var(--bz-focus); outline-offset: 3px; }
.btn.big.klok-check { min-width: 0; width: 100%; max-width: 240px; }

.klok-options { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.klok-options.n3 { grid-template-columns: minmax(0, 1fr); max-width: 360px; }
.klok-options.clocks { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 420px; }
.klok-option {
  min-height: 54px;
  padding: 8px 10px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font: 800 1.05rem/1.15 var(--font);
  cursor: pointer;
  box-shadow: 0 5px 0 #d6cff7;
  overflow-wrap: break-word;
  hyphens: auto;
  min-width: 0;
}
.klok-option.digits { font-size: 1.4rem; font-weight: 900; }
.klok-option.clock { padding: 6px; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.klok-option.clock .klok-svg { width: 100%; height: 100%; display: block; }
.klok-option:active { transform: translateY(3px); box-shadow: 0 2px 0 #d6cff7; }
.klok-option:focus-visible { outline: 4px solid var(--bz-focus); outline-offset: 3px; }
.klok-option.right { background: #dcf7d4; box-shadow: 0 5px 0 #7cc46f; }
.klok-option.wrong { background: #ffe0dc; box-shadow: 0 5px 0 #ff9a8b; animation: klok-shake 0.35s; }
@keyframes klok-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.klok-dots { display: flex; gap: 6px; justify-content: center; }
.klok-dot { width: 12px; height: 12px; border-radius: 50%; background: #ddd8f7; }
.klok-dot.now { background: var(--primary); box-shadow: 0 0 0 3px rgba(91, 75, 219, 0.25); }
.klok-dot.good { background: #3fb35f; }
.klok-dot.bad { background: #ff8a7a; }
.klok-status { margin: 0; min-height: 2.4em; font-size: 1rem; font-weight: 800; color: var(--primary-dark); text-align: center; line-height: 1.2; }

.klok-ov { display: inline-flex; width: 120px; height: 120px; }
.klok-ov svg { width: 100%; height: 100%; }

/* short phones: smaller prompt and buttons, so the clock keeps room */
@media (max-height: 640px) {
  .klok-prompt { min-height: 58px; padding: 6px 12px; }
  .klok-target { font-size: 1.25rem; }
  .klok-btn.round { width: 46px; height: 46px; font-size: 1.5rem; }
  .klok-option { min-height: 46px; font-size: 0.98rem; }
  .klok-status { min-height: 2.2em; font-size: 0.92rem; }
}

/* sideways phones: the clock on the left, everything else beside it */
@media (orientation: landscape) and (max-height: 520px) {
  #screen-klok { flex-direction: row; }
  .klok-hud { flex-direction: column; justify-content: space-between; padding: 10px 6px 10px 12px; }
  .klok-hud { max-width: 130px; }
  .klok-hud .hud-mid { flex: 0; }
  .klok-hud .hud-level { white-space: normal; font-size: 0.92rem; }
  #screen-klok[data-mode="read"] .klok-prompt { display: none; } /* the bar already asks it */
  .klok-hud .btn.icon { width: 54px; height: 54px; }
  #klok-stage {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "face prompt" "face side";
    align-items: start;
    gap: 8px 14px;
    padding: 8px 12px;
  }
  .klok-prompt { grid-area: prompt; width: 100%; min-height: 0; }
  .klok-face { grid-area: face; height: min(calc(100vh - 16px), 44vw); width: auto; max-width: 44vw; aspect-ratio: 220 / 238; }
  .klok-face.activity { aspect-ratio: auto; width: 40vw; }
  .klok-face.activity .klok-activity { max-height: min(calc(100vh - 40px), 230px); }
  .klok-dots { gap: 4px; }
  .klok-dot { width: 9px; height: 9px; }
  .klok-face .klok-svg { height: 100%; }
  .klok-side { grid-area: side; width: 100%; }
  .klok-options.clocks { max-width: 380px; }
  .klok-option.clock { max-height: 34vh; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .klok-option { font-size: 0.95rem; padding: 6px 8px; }
  .klok-nudges { gap: 8px 10px; }
  .klok-nudge { gap: 6px; }
  .klok-nudge-name { font-size: 0.85rem; white-space: normal; text-align: center; }
}
@media (orientation: landscape) and (max-height: 400px) {
  .klok-lead { font-size: 0.85rem; }
  .klok-target { font-size: 1.15rem; }
  .klok-digital { font-size: 0.95rem; }
  .klok-btn.round { width: 42px; height: 42px; font-size: 1.35rem; }
  .klok-check { min-height: 44px; padding-block: 6px; }
  .klok-option { min-height: 42px; }
  .klok-status { min-height: 1.2em; }
}

/* ---------- Digitaal: the digital clock, the day strip, the steppers ---------- */
.klok-face .klok-dig { width: min(100%, 340px); height: auto; max-height: 100%; display: block; }
.klok-face .klok-strip { width: min(100%, 400px); height: auto; max-height: 100%; display: block; }
.klok-colon.blink { animation: klok-blink 2s ease-in-out infinite; } /* calm: once every two seconds */
@keyframes klok-blink {
  0%, 45% { opacity: 1; }
  55%, 95% { opacity: 0.25; }
  100% { opacity: 1; }
}
.klok-dig-part.hint, .klok-btn.hint { animation: klok-pulse 0.75s ease-in-out infinite alternate; }
.klok-options.words { grid-template-columns: minmax(0, 1fr); max-width: 400px; gap: 8px; }
.klok-options.words .klok-option { hyphens: manual; }
.klok-options.digis { max-width: 420px; }
.klok-options.digis.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 480px; }
.klok-option.digi { padding: 6px; display: flex; align-items: center; justify-content: center; }
.klok-option.digi .klok-dig { width: 100%; max-width: 170px; height: auto; display: block; }
#screen-klok[data-mode="dig"] .klok-option { min-height: 54px; }
.klok-setrow { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
/* the digital clock being set, with + above and − below on each side: hours left, minutes right */
.klok-setter { width: min(100%, 340px); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0 8px; }
.klok-setter-display { grid-column: 2; grid-row: 1; width: 100%; }
.klok-setter-display .klok-dig { width: 100%; height: auto; display: block; }
.klok-steps { display: flex; flex-direction: column; gap: 8px; } /* + / up first: on top and first in the tab order */
.klok-steps.hour { grid-column: 1; grid-row: 1; }
.klok-steps.minute { grid-column: 3; grid-row: 1; }
.klok-steps .klok-btn.round { width: 54px; height: 54px; }
.klok-ov.pair { width: auto; height: auto; gap: 10px; align-items: center; }
.klok-ov.pair .klok-svg { width: 104px; height: 112px; }
.klok-ov.pair .klok-dig { width: 128px; height: auto; }
.klok-ov.strip { width: min(260px, 70vw); height: auto; }
.klok-ov.strip svg { height: auto; }
@media (max-height: 420px) {
  .klok-ov.pair .klok-svg { width: 78px; height: 84px; }
  .klok-ov.pair .klok-dig { width: 100px; }
  .klok-ov.strip { width: 190px; }
}

@media (max-height: 640px) {
  #screen-klok[data-mode="dig"] .klok-option { min-height: 48px; }
  .klok-steps .klok-btn.round { width: 48px; height: 48px; font-size: 1.5rem; }
  .klok-steps { gap: 6px; }
  #screen-klok[data-mode="dig"] .klok-check { min-height: 48px; padding-block: 6px; }
  .klok-option.digi .klok-dig { max-width: 140px; }
}

/* sideways phones: a smaller clock on the left, so the answers and the steppers get the room */
@media (orientation: landscape) and (max-height: 520px) {
  #screen-klok[data-mode="dig"] .klok-face { height: min(calc(100vh - 16px), 32vw); max-width: 32vw; }
  #screen-klok[data-mode="dig"] .klok-face[data-face="digital"], #screen-klok[data-mode="dig"] .klok-face[data-face="strip"] { aspect-ratio: auto; height: auto; width: 32vw; align-self: center; }
  #screen-klok[data-mode="dig"] .klok-target { font-size: 1.1rem; }
  #screen-klok[data-mode="dig"] .klok-target.small { font-size: 1rem; }
  #screen-klok[data-mode="dig"] .klok-lead { font-size: 0.85rem; }
  .klok-setter { max-width: 300px; gap: 0 6px; }
  .klok-setrow { gap: 8px; }
  .klok-options.words { gap: 6px; }
  .klok-options.words .klok-option { font-size: 0.92rem; padding: 4px 8px; }
  .klok-options.digis.n3 { grid-template-columns: minmax(0, 1fr); max-width: 220px; gap: 6px; }
  .klok-options.digis { gap: 6px; }
  .klok-option.digi { padding: 4px; }
  .klok-option.digi .klok-dig { max-width: 120px; }
}
@media (orientation: landscape) and (max-height: 400px) {
  #screen-klok[data-mode="dig"] .klok-option { min-height: 48px; }
  .klok-option.digi .klok-dig { max-width: 100px; }
  .klok-setter-display .klok-dig { max-height: 86px; }
}

/* ---------- Wekker zetten: the alarm clock with its arrows ---------- */
.klok-say { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.klok-setter-display .klok-alarm { width: 100%; height: auto; display: block; overflow: visible; }
.klok-btn.round.arrow svg { width: 30px; height: 30px; display: block; margin: auto; }
.klok-setter.alarm .klok-steps { min-width: 54px; } /* whole hours have no minute arrows: the clock stays in the middle */
.klok-btn.round.arrow.hour { color: var(--bz-on-accent); }
/* the alarm rings: the bells wiggle a little, three times */
.klok-bell { transform-box: fill-box; transform-origin: 50% 100%; }
.klok-setter-display.ringing .klok-bell { animation: klok-ring 0.18s ease-in-out 6 alternate; }
@keyframes klok-ring {
  from { transform: rotate(-9deg); }
  to { transform: rotate(9deg); }
}
.klok-ov.pair .klok-alarm { width: 128px; height: auto; }
#screen-klok[data-mode="alarm"] .klok-face[data-face="analog"] .klok-svg { max-height: 300px; }
#screen-klok[data-mode="alarm"] .klok-face[data-face="strip"] .klok-strip { width: min(100%, 360px); height: auto; max-height: 100%; display: block; }
#screen-klok[data-mode="alarm"] .klok-face.activity .klok-activity { max-height: 170px; }
@media (max-height: 640px) {
  #screen-klok[data-mode="alarm"] .klok-check { min-height: 48px; padding-block: 6px; }
  .klok-btn.round.arrow svg { width: 26px; height: 26px; }
  .klok-setter.alarm .klok-steps { min-width: 48px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #screen-klok[data-mode="alarm"] .klok-face { height: min(calc(100vh - 16px), 32vw); max-width: 32vw; }
  #screen-klok[data-mode="alarm"] .klok-face[data-face="strip"], #screen-klok[data-mode="alarm"] .klok-face[data-face="bed"] { aspect-ratio: auto; height: auto; width: 32vw; align-self: center; }
  #screen-klok[data-mode="alarm"] .klok-target { font-size: 1.1rem; }
  #screen-klok[data-mode="alarm"] .klok-lead { font-size: 0.85rem; }
}
@media (orientation: landscape) and (max-height: 400px) {
  .klok-setter.alarm .klok-setter-display .klok-alarm { max-height: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  .klok-hand.hint, .klok-daypart.hint, .klok-dig-part.hint, .klok-btn.hint { animation: none; filter: drop-shadow(0 0 6px rgba(255, 170, 0, 1)); }
  .klok-face.happy .klok-svg, .klok-option.wrong, .klok-colon.blink, .klok-setter-display.ringing .klok-bell { animation: none; }
}
