/* Everyday & Fun tools: loaded on every tool page of the category (see app/views/pages/tool.php). */

/* ---- "stage" tools: one thing to look at. The result sits on top, large and centred; the controls go under it. ---- */
body:is([data-tool="coin-flip"], [data-tool="dice-roller"], [data-tool="yes-or-no-generator"], [data-tool="random-number-generator"],
  [data-tool="love-calculator"], [data-tool="password-generator"], [data-tool="pomodoro-timer"]) .tool-box.panes { display: flex; flex-direction: column; }
body:is([data-tool="coin-flip"], [data-tool="dice-roller"], [data-tool="yes-or-no-generator"], [data-tool="random-number-generator"],
  [data-tool="love-calculator"], [data-tool="password-generator"], [data-tool="pomodoro-timer"]) .tool-res { order: -1; }
body:is([data-tool="coin-flip"], [data-tool="dice-roller"], [data-tool="yes-or-no-generator"], [data-tool="random-number-generator"],
  [data-tool="love-calculator"], [data-tool="password-generator"], [data-tool="pomodoro-timer"]) .tool-out:not(:empty) {
  min-height: 214px; align-content: center; margin: 0 0 18px; padding: 0 0 18px; border-top: 0; border-bottom: 1px dashed var(--line); }
body:is([data-tool="coin-flip"], [data-tool="dice-roller"], [data-tool="yes-or-no-generator"], [data-tool="random-number-generator"],
  [data-tool="love-calculator"], [data-tool="password-generator"]) .tool-in .tool-actions { justify-content: center; }
body:is([data-tool="coin-flip"], [data-tool="dice-roller"], [data-tool="yes-or-no-generator"], [data-tool="random-number-generator"],
  [data-tool="love-calculator"], [data-tool="password-generator"]) .tool-in .btn-primary { min-width: 230px; padding: 14px 28px; font-size: 1.08rem; }
body:is([data-tool="coin-flip"], [data-tool="dice-roller"], [data-tool="yes-or-no-generator"], [data-tool="random-number-generator"],
  [data-tool="love-calculator"], [data-tool="password-generator"]) .out-note { text-align: center; font-size: .85rem; }
.tool-box .life-big b { font-size: clamp(2.6rem, 11vw, 4.2rem); }
.tool-box .life-big b.idle { color: #a5b4fc; }
.tool-box .life-coin + b.idle { font-size: 1.5rem; color: var(--muted); }
.tool-box .life-coin { width: 132px; height: 132px; }
.tool-box .life-coin.idle { animation: none; opacity: .7; }

/* dice: bigger faces, the total is the headline */
body[data-tool="dice-roller"] .tool-box .life-die { min-width: 62px; height: 62px; font-size: 1.6rem; border-radius: 14px; box-shadow: 0 3px 0 #c7d2fe; }
body[data-tool="dice-roller"] .out-row.big, body[data-tool="random-number-generator"] .out-row.big { justify-content: center; }
body[data-tool="dice-roller"] .tool-out > .out-html { order: -1; }
body[data-tool="dice-roller"] .out-row.big .out-v { font-size: 2rem; }
body[data-tool="dice-roller"] .tool-out:not(:empty) { min-height: 0; }
@media (min-width: 621px) { body[data-tool="dice-roller"] .fields { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
body[data-tool="password-generator"] .tool-out:not(:empty) { min-height: 0; margin-bottom: 14px; padding-bottom: 14px; }
body[data-tool="random-number-generator"] .out-row.big { flex-direction: column; gap: 6px; padding: 20px 14px; text-align: center; }
body[data-tool="random-number-generator"] .out-row.big .out-l, body[data-tool="password-generator"] .out-row.big .out-l { flex: none; }
body[data-tool="random-number-generator"] .out-row.big .out-v { margin: 0; font-size: clamp(2.8rem, 12vw, 4.6rem); line-height: 1.05; text-align: center; }

/* password: the password itself is the hero */
body[data-tool="password-generator"] .out-row.big { flex-direction: column; align-items: center; gap: 10px; padding: 22px 16px; }
body[data-tool="password-generator"] .out-row.big .out-v { margin: 0; text-align: center; font-family: var(--mono); font-size: clamp(1.15rem, 4.6vw, 1.9rem);
  line-height: 1.35; letter-spacing: .03em; word-break: break-all; }
body[data-tool="password-generator"] .out-row.big .copy-btn { padding: 8px 22px; font-size: .9rem; }
body[data-tool="password-generator"] .out-row:not(.big) .out-v { font-family: var(--mono); word-break: break-all; }

/* pomodoro: the clock on top with its own buttons; the form under it is only settings */
body[data-tool="pomodoro-timer"] .tool-out:not(:empty) { min-height: 0; }
body[data-tool="pomodoro-timer"] .tool-in .tool-actions { display: none; }
body[data-tool="pomodoro-timer"] .tool-in::before { content: "Timer settings"; display: block; margin-bottom: 12px; font-size: .78rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
body[data-tool="pomodoro-timer"] .life-pomo .btn-primary { min-width: 150px; padding: 13px 26px; font-size: 1.05rem; }

/* spin the wheel, name picker, teams: list on the left, the draw on the right */
body:is([data-tool="spin-the-wheel"], [data-tool="random-name-picker"], [data-tool="random-team-generator"]) .tool-res { text-align: center; }
body:is([data-tool="spin-the-wheel"], [data-tool="random-name-picker"], [data-tool="random-team-generator"]) .out-table { text-align: left; }
body[data-tool="spin-the-wheel"] .life-wheel canvas { width: min(100%, 400px); }

/* QR codes: the code sits in the result panel, download buttons under it */
body:is([data-tool="qr-code-generator"], [data-tool="wifi-qr-code-generator"]) .tool-res { text-align: center; }
body:is([data-tool="qr-code-generator"], [data-tool="wifi-qr-code-generator"]) .tool-res .out-note { font-size: .85rem; }

/* rows tools (GPA, grades, electricity): rows left, running result right. Markup: app/views/tools/_life-rows.php */
.lr { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.lr-res { position: sticky; top: 80px; min-height: 240px; padding: 18px; border: 1px solid #dfe3f5; border-radius: 14px; background: linear-gradient(180deg, #f6f7ff, #fbfbfe); }
.lr-title { display: flex; align-items: center; gap: 6px; margin: 0 0 12px; font-size: .78rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--brand-ink); }
.lr-res .tool-out:not(:empty) { margin-top: 0; padding-top: 0; border-top: 0; }
.lr-res .out-row:not(.big) { background: #fff; }
.lr .life-rows { margin-bottom: 8px; }
.lr .lr-add { margin: 0 0 16px; }
@media (max-width: 900px) {
  .lr { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .lr-res { position: static; min-height: 0; order: -1; } /* phones: the running result first, the rows under it */
}

/* screen resolution: the detected size, big */
body[data-tool="screen-resolution-checker"] .out-row.big { flex-direction: column; gap: 4px; padding: 22px 14px; text-align: center; }
body[data-tool="screen-resolution-checker"] .out-row.big .out-l { flex: none; }
body[data-tool="screen-resolution-checker"] .out-row.big .out-v { margin: 0; font-size: clamp(2.2rem, 9vw, 3.6rem); line-height: 1.1; }
body[data-tool="screen-resolution-checker"] .tool-actions { justify-content: center; }

@media (prefers-reduced-motion: reduce) { .life-coin, .life-die { animation: none; } }

/* typing test: the length picker and the button share one line, so the text and the typing box stay in the first screen */
@media (min-width: 621px) {
  body[data-tool="typing-speed-test"] .tool-form { display: flex; align-items: flex-end; gap: 12px; }
  body[data-tool="typing-speed-test"] .tool-form .fields { flex: 1; grid-template-columns: minmax(0, 1fr); }
  body[data-tool="typing-speed-test"] .tool-form .tool-actions { margin-top: 0; flex-wrap: nowrap; }
}
body[data-tool="typing-speed-test"] .tool-out:not(:empty) { margin-top: 14px; padding-top: 14px; }
body[data-tool="typing-speed-test"] .life-type-text { max-height: 7.2em; margin: 10px 0; }

/* ---- sibling tabs (assets/js/tools/_life-modes.js): the row sits in space reserved here, so nothing moves when it is added ---- */
.tm-tabs { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; max-width: calc(100% - 28px); padding: 4px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--soft); overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.tm-tabs::-webkit-scrollbar { display: none; }
.tm-tabs a { flex: none; padding: 6px 14px; border-radius: 999px; font: 600 .86rem var(--font); color: var(--muted); }
.tm-tabs a:hover { background: #fff; color: var(--ink); text-decoration: none; }
.tm-tabs a.on { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
body:is([data-tool="pomodoro-timer"], [data-tool="qr-code-generator"], [data-tool="wifi-qr-code-generator"], [data-tool="password-generator"],
  [data-tool="password-strength-checker"], [data-tool="coin-flip"], [data-tool="dice-roller"], [data-tool="random-number-generator"],
  [data-tool="yes-or-no-generator"], [data-tool="spin-the-wheel"], [data-tool="random-name-picker"]) .tool-box { position: relative; padding-top: 66px; }

/* ---- one-tap presets above the options, and the short history under a result ---- */
.life-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 14px; font-size: .82rem; color: var(--muted); }
.life-presets .chip { padding: 5px 13px; font-size: .84rem; }
body:is([data-tool="dice-roller"], [data-tool="random-number-generator"]) .life-presets { justify-content: center; }
.life-hist { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 12px 0 0; font-size: .8rem; color: var(--muted); }
.tool-box .life-hist b { padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tool-box .life-hist b.now { border-color: var(--brand); color: var(--brand-ink); }

/* the coin and the dice are buttons: tap them to go again */
.tool-box button.life-coin { padding: 0; font-family: inherit; cursor: pointer; transition: filter .15s; }
.tool-box button.life-coin:hover { filter: brightness(1.06); }
.tool-box button.life-dice { width: 100%; padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.tool-box button.life-dice:hover .life-die { border-color: var(--brand-ink); }

/* phones: the QR code is live, so show it before the options */
@media (max-width: 900px) {
  body[data-tool="qr-code-generator"] .tool-box.panes .tool-res { order: -1; }
  body[data-tool="qr-code-generator"] .life-qr canvas { width: min(100%, 180px); }
}

/* reserve the height of the first result, so the controls under it do not jump when it is drawn */
body[data-tool="dice-roller"] .tool-res { min-height: 330px; }
body[data-tool="random-number-generator"] .tool-res { min-height: 262px; }
body[data-tool="coin-flip"] .tool-res { min-height: 252px; }
body[data-tool="password-generator"] .tool-res { min-height: 252px; }
body[data-tool="pomodoro-timer"] .tool-res { min-height: 277px; }
/* rows tools: the starter rows and the first result are drawn by the script, so their height is reserved */
body[data-tool="gpa-calculator"] .life-rows, body[data-tool="electricity-bill-calculator"] .life-rows { min-height: 398px; }
body[data-tool="grade-calculator"] .life-rows { min-height: 296px; }
@media (max-width: 900px) {
  body[data-tool="password-generator"] .tool-res { min-height: 279px; }
  body[data-tool="pomodoro-timer"] .tool-res { min-height: 328px; }
  body[data-tool="gpa-calculator"] .lr-res { min-height: 382px; }
  body[data-tool="grade-calculator"] .lr-res { min-height: 724px; }
  body[data-tool="electricity-bill-calculator"] .lr-res { min-height: 832px; }
}
@media (max-width: 560px) {
  body[data-tool="gpa-calculator"] .life-rows { min-height: 710px; }
  body[data-tool="grade-calculator"] .life-rows { min-height: 530px; }
  body[data-tool="electricity-bill-calculator"] .life-rows { min-height: 894px; }
}
