/* style.css - charte clearcheck studio : encre, soleil, tomate, cobalt, pin, creme. Police systeme uniquement. */
:root {
  --ink: #17140F; --sun: #FFC52E; --tomato: #D9371F; --cobalt: #2F44E8; --pine: #0F5C49; --cream: #FBF7EE;
  --sand: #E8C98A; --earth: #B5642C; --indigo: #2B3A67;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--ink); font-family: var(--font); overflow: hidden;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--ink); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- HUD */
#hud { display: flex; flex-direction: column; gap: 4px; padding: calc(6px + var(--sat)) max(calc(10px + var(--sar)), calc((100% - 460px) / 2)) 8px max(calc(10px + var(--sal)), calc((100% - 460px) / 2));
  background: var(--ink); color: var(--cream); z-index: 5; }
.hud-top { display: flex; align-items: center; gap: 8px; }
.hud-goal { flex: 1; min-width: 0; font-size: 14px; font-weight: 800; color: var(--sun); line-height: 1.2; }
.hud-row { display: flex; align-items: center; gap: 10px; }
.hud-pct { font-size: 28px; font-weight: 900; line-height: 1; min-width: 64px; font-variant-numeric: tabular-nums; }
.gauge { position: relative; flex: 1; height: 18px; border-radius: 10px; background: #3a342b; overflow: hidden; border: 2px solid #6b6254; min-width: 40px; }
.gauge i { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: linear-gradient(90deg, var(--sun), var(--tomato)); border-radius: 6px; transition: width .12s linear; }
.gauge b { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(251,247,238,.7); }
.hud-time { font-size: 20px; font-weight: 800; min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.hud-time.low { color: var(--tomato); }
.hud-btns { display: flex; gap: 8px; }

/* ---- boutons */
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.icon-btn { width: 46px; height: 46px; border-radius: 14px; border: 2.5px solid var(--cream); background: rgba(251,247,238,.1); color: var(--cream);
  display: grid; place-items: center; padding: 0; flex: none; touch-action: manipulation; }
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn.txt { font-weight: 900; font-size: 15px; }
.screen .icon-btn { border-color: var(--ink); color: var(--ink); background: var(--cream); box-shadow: 0 3px 0 var(--ink); }
.icon-btn[aria-pressed="true"] { background: var(--sun); color: var(--ink); }
.btn { min-height: 52px; min-width: 52px; padding: 0 20px; border-radius: 16px; border: 3px solid var(--ink); background: var(--cream); color: var(--ink);
  font-weight: 800; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 4px 0 var(--ink); touch-action: manipulation; transition: transform .06s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn svg { width: 24px; height: 24px; flex: none; }
.btn.big { min-height: 64px; min-width: 64px; padding: 0 28px; font-size: 21px; border-radius: 20px; }
.btn.big svg { width: 30px; height: 30px; }
.btn.primary { background: var(--sun); }
.btn.ghost { background: transparent; box-shadow: none; border-color: var(--ink); }
.btn.icon-only { padding: 0; width: 56px; }
.btn[disabled] { opacity: .45; }

/* ---- scene */
#stage { position: relative; flex: 1; min-height: 0; background: var(--earth); }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.banner { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 9px 16px;
  background: var(--ink); color: var(--cream); border: 3px solid var(--sun); border-radius: 16px; font-weight: 900; font-size: 18px; text-align: center; line-height: 1.2;
  animation: bn 2.6s ease both; pointer-events: none; z-index: 3; }
@keyframes bn { 0% { opacity: 0; transform: translate(-50%, -14px); } 12% { opacity: 1; transform: translate(-50%, 0); } 82% { opacity: 1; } 100% { opacity: 0; } }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; z-index: 4;
  padding: calc(14px + var(--sat)) calc(16px + var(--sar)) calc(14px + var(--sab)) calc(16px + var(--sal)); overflow-y: auto; touch-action: pan-y; }
.screen.scrim { background: rgba(23,20,15,.72); }
.card { background: var(--cream); border: 3px solid var(--ink); border-radius: 24px; padding: 20px 18px; width: min(100%, 420px); box-shadow: 0 6px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 12px; }
.card.wide { width: min(100%, 460px); }
.card h2 { margin: 0; font-size: 24px; font-weight: 900; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hint { margin: 0; font-size: 13px; color: #5b5244; text-align: center; line-height: 1.35; }
.quiet-link { font-size: 13px; color: #5b5244; text-decoration: underline; text-underline-offset: 3px; word-break: break-all; }

/* ---- titre */
.title { background: linear-gradient(180deg, rgba(23,20,15,.78) 0%, rgba(23,20,15,.35) 55%, rgba(23,20,15,.7) 100%); color: var(--cream); }
.wordmark { display: flex; gap: 2px; font-size: clamp(64px, 20vw, 108px); font-weight: 900; line-height: 1; }
.wordmark span { color: var(--sun); text-shadow: 3px 4px 0 var(--ink), 0 0 0 var(--ink); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.wordmark span:nth-child(2) { animation-delay: .12s; color: var(--cream); } .wordmark span:nth-child(3) { animation-delay: .24s; color: var(--tomato); }
.wordmark span:nth-child(4) { animation-delay: .36s; color: var(--cream); } .wordmark span:nth-child(5) { animation-delay: .48s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.goal-line { margin: 0; font-size: clamp(20px, 5.4vw, 26px); font-weight: 800; text-align: center; max-width: 18em; text-shadow: 0 2px 0 var(--ink); }
.title-foot { display: flex; gap: 12px; margin-top: 6px; }
.title .btn { border-color: var(--ink); }

/* ---- niveaux */
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.lv { position: relative; min-height: 88px; border: 3px solid var(--ink); border-radius: 16px; background: #fff; box-shadow: 0 3px 0 var(--ink); padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; touch-action: manipulation; }
.lv b { font-size: 26px; line-height: 1; } .lv small { font-size: 13px; font-weight: 700; line-height: 1.15; text-align: center; }
.lv[disabled] { background: #d8d0bf; opacity: .75; box-shadow: none; }
.lv .st, .dc-stars { display: flex; gap: 1px; } .lv .st svg, .dc-stars svg { width: 15px; height: 15px; }
.lv svg.lockic { width: 22px; height: 22px; }
.daily-card { width: 100%; min-height: 64px; display: flex; align-items: center; gap: 12px; border: 3px solid var(--ink); border-radius: 16px; background: var(--sun); box-shadow: 0 3px 0 var(--ink); padding: 8px 14px; text-align: left; touch-action: manipulation; }
.daily-card > svg { width: 30px; height: 30px; flex: none; } .dc-main { display: flex; flex-direction: column; flex: 1; }
.dc-main b { font-size: 17px; } .dc-main small { font-size: 13px; font-weight: 700; }

/* ---- fin de manche */
.end { justify-content: flex-start; padding-top: calc(16px + var(--sat)); padding-bottom: calc(120px + var(--sab)); }
.end-level { font-size: 14px; font-weight: 800; color: #5b5244; text-transform: uppercase; letter-spacing: .06em; }
.end-msg { font-size: 22px; font-weight: 900; text-align: center; min-height: 1.2em; }
.end-pct { font-size: 76px; font-weight: 900; line-height: 1; display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.end-pct small { font-size: 32px; }
.stars { display: flex; gap: 8px; } .stars svg { width: 46px; height: 46px; } .stars svg.pop { animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes pop { 0% { transform: scale(.2) rotate(-40deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.end-meta { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 14px; font-weight: 700; color: #3c352a; }
#end-img { width: min(46vw, 180px); height: auto; aspect-ratio: 1; border-radius: 14px; border: 3px solid var(--ink); background: var(--sand); -webkit-user-select: auto; user-select: auto; -webkit-touch-callout: default; touch-action: manipulation; }
#end-text { width: 100%; font: 700 13px/1.4 ui-monospace, Menlo, Consolas, monospace; text-align: center; border: 3px solid var(--ink); border-radius: 12px; padding: 8px; background: #fff; color: var(--ink); resize: none; -webkit-user-select: text; user-select: text; touch-action: manipulation; }
.end-actions { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; justify-content: center; align-items: center; z-index: 6; padding: 12px calc(12px + var(--sar)) calc(12px + var(--sab)) calc(12px + var(--sal));
  background: linear-gradient(0deg, rgba(23,20,15,.95) 60%, rgba(23,20,15,0)); }
.end-actions[hidden] { display: none; }

/* ---- reglages */
.set-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.switch { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 12px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; font-weight: 800; font-size: 16px; touch-action: manipulation; }
.switch i { width: 46px; height: 26px; border-radius: 14px; background: #bdb4a2; border: 2.5px solid var(--ink); position: relative; transition: background .12s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--cream); border: 2px solid var(--ink); transition: transform .12s; }
.switch[aria-checked="true"] i { background: var(--pine); } .switch[aria-checked="true"] i::after { transform: translateX(20px); }
.set-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; font-weight: 800; flex-wrap: wrap; }
.seg { display: flex; gap: 8px; } .seg button { min-width: 48px; min-height: 48px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; font-weight: 900; padding: 0 10px; touch-action: manipulation; }
.seg button[aria-pressed="true"] { background: var(--sun); box-shadow: 0 3px 0 var(--ink); }
.skins button { position: relative; width: 48px; padding: 0; } .skins .sw { display: block; width: 26px; height: 26px; border-radius: 50%; margin: auto; border: 3px solid var(--ink); }
.skins button[disabled] { opacity: .5; } .skins small { position: absolute; bottom: -2px; right: 0; font-size: 12px; background: var(--ink); color: var(--cream); border-radius: 6px; padding: 0 3px; }
.skins button:nth-child(2) .sw { border-radius: 6px; } .skins button:nth-child(3) .sw { border-radius: 4px; transform: rotate(45deg) scale(.85); } .skins button:nth-child(4) .sw { border-radius: 13px / 8px; }

/* ---- credits */
.credits h2 { text-align: center; }
.credits img { border-radius: 20px; border: 3px solid var(--ink); background: var(--cream); }
.credits p { margin: 0; text-align: center; font-weight: 700; } .credits .ver { opacity: .6; }

/* ---- options */
body.hc .btn, body.hc .icon-btn, body.hc .card { border-width: 4px; }
body.reduce .wordmark span { animation: none; } body.reduce .banner { animation-duration: 2.6s; } body.reduce .stars svg.pop { animation: none; }
@media (prefers-reduced-motion: reduce) { .wordmark span { animation: none; } .stars svg.pop { animation: none; } }
@media (max-height: 560px) { .wordmark { font-size: 56px; } .end-pct { font-size: 52px; } .stars svg { width: 36px; height: 36px; } .card { padding: 14px; gap: 8px; } }
@media (min-width: 700px) and (orientation: landscape) { .hud-pct { font-size: 34px; } }
#selftest-out { position: fixed; inset: 0; margin: 0; padding: 12px; background: #fff; color: #000; font: 12px/1.35 ui-monospace, Menlo, monospace; overflow: auto; z-index: 99; white-space: pre-wrap; -webkit-user-select: text; user-select: text; }
