/* Kid side: bubbly, chunky, colourful. Teacher pages use teacher.css. */
@font-face {
  font-family: "Fredoka";
  src: url("../fonts/Fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}

body.kid {
  --sky: #3f8efc; --sky-dark: #2b6fd1; --sky-light: #e3eeff;
  --sun: #ff9f1c; --sun-dark: #d97d00; --sun-light: #fff1dc;
  --berry: #e4457a; --berry-light: #fde3ec;
  --mint: #e9f8ef;
  font-family: "Fredoka", "Varela Round", "Nunito", system-ui, sans-serif;
  font-size: 20px;
  color: var(--ink);
  background: var(--mint);
  background-image:
    radial-gradient(circle at 8% 12%, rgba(63, 142, 252, .18) 0, rgba(63, 142, 252, 0) 28%),
    radial-gradient(circle at 92% 18%, rgba(255, 159, 28, .20) 0, rgba(255, 159, 28, 0) 26%),
    radial-gradient(circle at 80% 90%, rgba(46, 139, 87, .18) 0, rgba(46, 139, 87, 0) 30%),
    radial-gradient(circle at 15% 85%, rgba(228, 69, 122, .14) 0, rgba(228, 69, 122, 0) 26%);
  background-attachment: fixed;
}
body.kid h1, body.kid h2, body.kid h3, body.kid .tile, body.kid .big-btn, body.kid .pill-btn { letter-spacing: .01em; }

/* Top bar */
.kid-top { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1.2rem; max-width: 760px; margin: 0 auto; }
.brand-mini { display: inline-flex; align-items: center; gap: .3rem; color: var(--green-dark); font-weight: 600; font-size: 1rem; }
.pill-btn { display: inline-flex; align-items: center; gap: .3rem; text-decoration: none; font-weight: 600; font-size: 1rem; color: #fff; background: var(--green); border: 0; border-radius: 999px; padding: .45rem 1.1rem; cursor: pointer; box-shadow: 0 3px 0 var(--green-dark); }
.pill-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--green-dark); }
.pill-btn.ghost { background: #fff; color: var(--green-dark); box-shadow: 0 3px 0 var(--line); }
.pill-btn.ghost:active { box-shadow: 0 1px 0 var(--line); }
.kid-wrap { max-width: 760px; margin: 0 auto; padding: 0 1.2rem 3rem; }

/* Headings */
h1 { font-size: 2.6rem; line-height: 1.1; text-align: center; margin: .6rem 0 1rem; font-weight: 700; }
h1.account-name { font-size: clamp(2.2rem, 7vw, 3.4rem); color: var(--green-dark); }
h1.brand { font-size: clamp(2rem, 7vw, 3rem); color: var(--green-dark); margin-top: 3rem; display: flex; justify-content: center; align-items: center; gap: .3rem; }
h1.page-title { display: flex; justify-content: center; align-items: center; gap: .5rem; }
h1.page-title .ico { width: 1.2em; height: 1.2em; }
h1.page-title.t-paycheck { color: var(--green-dark); } h1.page-title.t-jobs { color: var(--sky-dark); } h1.page-title.t-store { color: var(--sun-dark); }
h2 { font-size: 1.4rem; margin: 1.2rem 0 .5rem; font-weight: 600; }
.section-title { text-align: center; margin-top: 2rem; }
.lead { font-size: 1.2em; text-align: center; color: var(--muted); }
.balance-line { text-align: center; font-size: clamp(1.4rem, 5vw, 2.2rem); margin: .4rem 0; }
.balance-line.small { font-size: 1.3rem; }
.balance-line .amount { color: var(--green-dark); font-size: 1.3em; font-weight: 700; }
.balance-line .amount.neg { color: var(--red); }

/* Cards: thick coloured rim with a flat offset shadow, like a sticker. */
.card, .balance-card, .summary div, .summary-box, .statement-panel, .stub, .job-card, .item, .confirm-page, dialog.confirm, .login-form {
  background: var(--card); border-radius: 26px; border: 3px solid var(--line); box-shadow: 0 5px 0 var(--line);
}

/* Balance card */
.money-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: center; max-width: 900px; margin: 0 auto 1rem; }
.balance-card { display: flex; flex-direction: column; align-items: center; padding: .5rem 2.2rem .7rem; border-color: var(--green); box-shadow: 0 6px 0 var(--green-dark); }
.balance-label { display: inline-flex; align-items: center; gap: .35rem; font-size: 1.05rem; font-weight: 600; color: var(--muted); }
.balance-label .ico { width: 1.3em; height: 1.3em; }
.balance-card .amount { font-size: clamp(2.6rem, 8vw, 3.6rem); line-height: 1.05; font-weight: 700; color: var(--green-dark); }
.balance-card.neg { border-color: var(--red); box-shadow: 0 6px 0 #8f2a1f; }
.balance-card.neg .amount { color: var(--red); }

.summary-box { padding: .6rem 1.4rem; text-align: center; font-size: 1.5rem; font-weight: 700; }
.money-row .in { justify-self: end; } .money-row .out { justify-self: start; }
.summary-box.in { border-color: var(--green); box-shadow: 0 5px 0 var(--green); background: var(--green-light); }
.summary-box.out { border-color: var(--berry); box-shadow: 0 5px 0 var(--berry); background: var(--berry-light); }
.summary-box.out .neg { color: var(--berry); }
.summary-box .label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* Buttons (tiles) */
.tiles { display: grid; gap: 1.1rem; max-width: 420px; margin: 0 auto; }
.tile { position: relative; display: flex; align-items: center; gap: .9rem; text-decoration: none; color: #fff; border-radius: 28px; padding: 1.1rem 1.3rem; font-size: 1.9rem; font-weight: 700; min-height: 96px; border: 3px solid rgba(255, 255, 255, .55); }
.tile .ico { flex: none; width: 2.6rem; height: 2.6rem; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .15)); }
.tile-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.tile-sub { display: block; font-size: 1rem; font-weight: 500; opacity: .92; margin-top: .25rem; }
.tile:active { transform: translateY(3px); }
.tile.t-paycheck { background: var(--green); box-shadow: 0 6px 0 var(--green-dark); }
.tile.t-jobs { background: var(--sky); box-shadow: 0 6px 0 var(--sky-dark); }
.tile.t-store { background: var(--sun); box-shadow: 0 6px 0 var(--sun-dark); }
.tile.t-paycheck:active { box-shadow: 0 2px 0 var(--green-dark); }
.tile.t-jobs:active { box-shadow: 0 2px 0 var(--sky-dark); }
.tile.t-store:active { box-shadow: 0 2px 0 var(--sun-dark); }
.badge { position: absolute; top: -14px; right: -10px; min-width: 42px; height: 42px; border-radius: 999px; color: #fff; font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 .5rem; border: 3px solid #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.badge.red { background: var(--berry); } .badge.green { background: var(--green-dark); }

.big-btn { display: block; width: 100%; text-align: center; text-decoration: none; padding: .9rem 1rem; border-radius: 999px; font-size: 1.3rem; font-weight: 700; border: 3px solid var(--green); background: var(--card); color: var(--green-dark); cursor: pointer; box-shadow: 0 4px 0 var(--green); }
.big-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--green); }
.big-btn.primary { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-dark); }
.big-btn.primary:active { box-shadow: 0 2px 0 var(--green-dark); }

/* Login */
.login-form { max-width: 420px; margin: 1.5rem auto; display: grid; gap: .4rem; padding: 1.4rem 1.4rem 1.6rem; }
.login-form label { font-weight: 600; margin-top: .6rem; }
.login-form input { font-size: 1.3rem; padding: .7rem 1rem; border: 3px solid var(--line); border-radius: 999px; font-family: inherit; }
.login-form input:focus { outline: none; border-color: var(--green); }
.login-form .big-btn { margin-top: 1rem; }

/* Statement */
.statement { font-size: .95rem; }
.statement td { border-bottom: 2px dotted var(--line); padding: .5rem .5rem; }
.statement tr:last-child td { border-bottom: 0; }
.statement .date { white-space: nowrap; color: var(--muted); }
.statement tr.kind-fine td:nth-child(2) { color: var(--red); }
.statement tr.kind-paycheck td:nth-child(2) { color: var(--green-dark); font-weight: 600; }
.statement .amt { display: inline-block; border-radius: 999px; padding: .05em .55em; font-weight: 600; }
.statement .amt.pos { background: var(--green-light); color: var(--green-dark); }
.statement .amt.neg { background: var(--berry-light); color: var(--berry); }
.statement .running { color: var(--muted); }
.statement tr.is-new td { background: var(--sun-light); }
.statement tr.is-new td:first-child { border-radius: 14px 0 0 14px; }
.statement tr.is-new td:last-child { border-radius: 0 14px 14px 0; }
.new-pill { display: inline-block; background: var(--berry); color: #fff; border-radius: 999px; font-size: .7em; font-weight: 700; padding: .1em .6em; vertical-align: middle; }
.statement-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.statement-wrap > .badge { z-index: 2; }
.new-banner { display: flex; align-items: center; justify-content: center; gap: .4rem; margin: .7rem 0 .3rem; padding: .5rem .8rem; border-radius: 999px; background: var(--sun-light); color: var(--sun-dark); font-weight: 600; font-size: 1rem; text-align: center; }
.statement-panel { flex: 1; min-height: 0; overflow-y: auto; padding: 0 .9rem .7rem; overscroll-behavior: contain; }
.month-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0; padding: .7rem 0 .4rem; background: var(--card); font-size: 1rem; }
.month-chip { background: var(--green-dark); color: #fff; border-radius: 999px; padding: .15em .9em; font-size: 1.05rem; font-weight: 600; }
.statement-panel .statement { margin-bottom: .8rem; }

/* Home: fills the screen, no page scroll. Balance + scrolling statement left (read first), buttons right. */
body.fit { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.fit .kid-top { flex: none; width: 100%; max-width: 1200px; }
body.fit .kid-wrap { flex: 1; min-height: 0; width: 100%; max-width: 1200px; padding-bottom: 1.2rem; display: flex; flex-direction: column; }
body.fit .account-name { margin: 0 0 .8rem; }
.home { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, 1fr); gap: 1.8rem; }
.home-buttons { display: flex; flex-direction: column; justify-content: center; min-height: 0; }
.home-buttons .tiles { width: 100%; }
.home-money { display: flex; flex-direction: column; min-height: 0; }

/* Pay stubs */
.stub { padding: .6rem 1.1rem 1rem; margin-bottom: 1.1rem; }
.stub.upcoming { border-color: var(--green); box-shadow: 0 5px 0 var(--green); }
.stub h2 { margin: .4rem 0 0; }
.stub-table { font-size: 1rem; margin-top: .5rem; }
.stub-table td, .stub-table th { border-bottom: 2px dotted var(--line); }
.stub-table tr.st-absent td, .stub-table tr.st-no_school td { color: var(--muted); }
.stub-table tr.st-absent td:nth-child(2) { color: var(--red); font-weight: 600; }
.stub-table tr.st-future td { color: var(--muted); font-style: italic; }
.stub-table tr.st-job td { color: var(--sky-dark); font-weight: 600; }
.stub-table tr.st-bonus td { color: var(--sun-dark); font-weight: 700; }
.stub-table tfoot th { font-size: 1.15rem; color: var(--ink); border-bottom: 0; padding-top: .8rem; }
.tag { font-family: inherit; }
details.stub summary { display: flex; justify-content: space-between; cursor: pointer; font-size: 1.1rem; padding: .4rem 0; list-style: none; font-weight: 600; }
details.stub summary::-webkit-details-marker { display: none; }
details.stub summary::before { content: "▸ "; color: var(--green-dark); }
details[open].stub summary::before { content: "▾ "; }

/* Jobs */
.job-card { padding: .6rem 1.3rem 1.3rem; margin-bottom: 1.1rem; }
.job-card.this { border-color: var(--sky); box-shadow: 0 6px 0 var(--sky-dark); background: var(--sky-light); }
.job-title { font-size: 1.9rem; font-weight: 700; color: var(--sky-dark); }
.job-pay { display: inline-block; margin-top: .4rem; background: var(--green-light); color: var(--green-dark); border-radius: 999px; padding: .15em .9em; font-weight: 600; }
.job + .job { border-top: 2px dotted var(--line); margin-top: .8rem; padding-top: .8rem; }

/* Store */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.item { padding: .9rem; text-align: center; display: flex; flex-direction: column; gap: .3rem; border-color: var(--sun); box-shadow: 0 5px 0 var(--sun); }
.item.cant { opacity: .65; border-color: var(--line); box-shadow: 0 5px 0 var(--line); }
.item img, .item .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 18px; background: var(--sun-light); display: flex; align-items: center; justify-content: center; font-size: 4rem; }
.item h3 { margin: .3rem 0 0; font-size: 1.25rem; font-weight: 600; }
.item p { margin: 0; font-size: .9rem; }
.item .price { font-size: 1.5rem; font-weight: 700; color: var(--sun-dark); }
.item .sold { font-weight: 600; color: var(--muted); padding: .5rem; }
.purchases { list-style: none; padding: 0; font-size: 1rem; }
.purchases li { padding: .5rem 0; border-bottom: 2px dotted var(--line); }

.leaf { vertical-align: -0.1em; }

dialog.confirm { padding: 1.5rem; max-width: 420px; width: 90vw; text-align: center; font-size: 1.1rem; border-color: var(--green); box-shadow: 0 6px 0 var(--green-dark); }
dialog.confirm::backdrop { background: rgba(29, 43, 36, .55); }
dialog.confirm h3 { margin: 0 0 .6rem; font-size: 1.6rem; }
dialog.confirm .big-btn { margin-top: .7rem; }
.confirm-page { text-align: center; max-width: 480px; margin: 0 auto; display: grid; gap: .6rem; padding: 1.2rem; }
.confirm-page img { width: 60%; max-width: 260px; aspect-ratio: 1; object-fit: cover; border-radius: 18px; margin: 0 auto; }

/* Phones held upright: statement first, then a row of three buttons. */
@media (max-width: 760px) {
  .home { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; gap: .7rem; }
  .home-buttons { justify-content: flex-start; }
  body.fit .account-name { font-size: 1.7rem; margin: .1rem 0 .4rem; }
  .home-buttons .tiles { grid-template-columns: repeat(3, 1fr); gap: .7rem; max-width: none; }
  .home-buttons .tile { flex-direction: column; justify-content: center; gap: .15rem; font-size: 1.05rem; min-height: 78px; padding: .6rem .3rem; border-radius: 20px; }
  .home-buttons .tile .ico { width: 1.7rem; height: 1.7rem; }
  .home-buttons .tile-text { align-items: center; }
  .tile-sub { font-size: .7rem; margin-top: .05rem; }
  .tile-sub .sofar { display: none; }
  .home-buttons .badge { top: -10px; right: -6px; min-width: 30px; height: 30px; font-size: .9rem; }
  .money-row { grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .6rem; }
  .money-row .balance-card { grid-column: 1 / -1; grid-row: 1; padding: .3rem .8rem .5rem; }
  .balance-card .amount { font-size: 2.1rem; }
  .balance-label { font-size: .9rem; }
  .summary-box { padding: .35rem; font-size: 1.1rem; }
  .money-row .in, .money-row .out { justify-self: stretch; }
  .statement { font-size: .85rem; }
  .statement td { padding: .4rem .3rem; }
  .new-banner { font-size: .9rem; padding: .35rem .7rem; }
}

/* ---- Motion: pop-in on load, pop-out on hover. Hover only where there is a real pointer. ---- */
@keyframes pop-in { 0% { opacity: 0; transform: scale(.85) translateY(10px); } 70% { opacity: 1; transform: scale(1.03) translateY(-2px); } 100% { transform: scale(1) translateY(0); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg) scale(1.15); } 75% { transform: rotate(10deg) scale(1.15); } }
@keyframes coin-spin { from { transform: rotateY(0); } to { transform: rotateY(360deg); } }
@keyframes bell-ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(18deg); } 40% { transform: rotate(-14deg); } 60% { transform: rotate(8deg); } 80% { transform: rotate(-4deg); } }

.tile, .balance-card, .summary-box, .statement-panel, .stub, .job-card, .item, .login-form { animation: pop-in .45s cubic-bezier(.2, .9, .3, 1.3) backwards; }
.tiles .tile:nth-child(2), .summary-box.in { animation-delay: .08s; }
.tiles .tile:nth-child(3), .summary-box.out { animation-delay: .16s; }
.statement-panel { animation-delay: .12s; }
.shelf .item:nth-child(2) { animation-delay: .06s; } .shelf .item:nth-child(3) { animation-delay: .12s; } .shelf .item:nth-child(4) { animation-delay: .18s; } .shelf .item:nth-child(n+5) { animation-delay: .24s; }

.tile, .pill-btn, .big-btn, .balance-card, .summary-box, .month-chip, .new-banner, .statement tr, .statement .amt, .stub, .job-card, .item, details.stub summary, .badge {
  transition: transform .18s cubic-bezier(.2, .9, .3, 1.4), box-shadow .18s ease, background-color .18s ease, font-size .18s ease;
}
.tile .ico, .balance-label .ico, .new-banner .ico { transition: transform .2s ease; }

@media (hover: hover) and (pointer: fine) {
  .tile:hover { transform: scale(1.05) translateY(-4px); }
  .tile.t-paycheck:hover { box-shadow: 0 10px 0 var(--green-dark), 0 14px 24px rgba(0, 0, 0, .12); }
  .tile.t-jobs:hover { box-shadow: 0 10px 0 var(--sky-dark), 0 14px 24px rgba(0, 0, 0, .12); }
  .tile.t-store:hover { box-shadow: 0 10px 0 var(--sun-dark), 0 14px 24px rgba(0, 0, 0, .12); }
  .tile:hover .ico { animation: wiggle .5s ease; }
  .tile:hover .badge { transform: scale(1.15) rotate(-8deg); }

  .balance-card:hover { transform: scale(1.06); box-shadow: 0 9px 0 var(--green-dark), 0 14px 24px rgba(0, 0, 0, .12); }
  .balance-card:hover .ico { animation: coin-spin .7s ease; }
  .summary-box:hover { transform: scale(1.08) translateY(-2px); }
  .summary-box.in:hover { box-shadow: 0 8px 0 var(--green), 0 12px 20px rgba(0, 0, 0, .1); }
  .summary-box.out:hover { box-shadow: 0 8px 0 var(--berry), 0 12px 20px rgba(0, 0, 0, .1); }

  .statement tr { position: relative; }
  .statement tr:hover { transform: scale(1.04); background: var(--card); box-shadow: 0 6px 16px rgba(0, 0, 0, .14); border-radius: 14px; z-index: 2; }
  .statement tr:hover td { font-size: 1.12em; border-bottom-color: transparent; background: var(--card); }
  .statement tr:hover td:first-child { border-radius: 14px 0 0 14px; }
  .statement tr:hover td:last-child { border-radius: 0 14px 14px 0; }
  .statement tr.is-new:hover td { background: var(--sun-light); }
  .statement tr:hover .amt { transform: scale(1.12); }
  .month-chip:hover { transform: scale(1.08); }
  .new-banner:hover { transform: scale(1.03); }
  .new-banner:hover .ico { animation: bell-ring .6s ease; }

  .pill-btn:hover { transform: translateY(-2px) scale(1.04); }
  .big-btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 6px 0 var(--green), 0 10px 18px rgba(0, 0, 0, .12); }
  .big-btn.primary:hover { box-shadow: 0 6px 0 var(--green-dark), 0 10px 18px rgba(0, 0, 0, .12); }
  .stub:hover, .job-card:hover, .item:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 9px 0 var(--line), 0 14px 24px rgba(0, 0, 0, .12); }
  .stub.upcoming:hover { box-shadow: 0 9px 0 var(--green), 0 14px 24px rgba(0, 0, 0, .12); }
  .job-card.this:hover { box-shadow: 0 9px 0 var(--sky-dark), 0 14px 24px rgba(0, 0, 0, .12); }
  .item:hover { box-shadow: 0 9px 0 var(--sun), 0 14px 24px rgba(0, 0, 0, .12); }
  .item.cant:hover { transform: none; box-shadow: 0 5px 0 var(--line); }
  details.stub summary:hover { transform: scale(1.02); color: var(--green-dark); }
  .stub-table tr:hover td { background: var(--green-light); }
}

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

/* login page: privacy link */
.login-form .class-line { margin: .2rem 0 .4rem; font-size: 1.05rem; }
.login-form .class-line a { margin-left: .5rem; font-size: .9rem; color: var(--muted, #6b7a72); }
.login-form .muted { font-weight: 400; font-size: .9rem; color: var(--muted, #6b7a72); }
.login-foot { text-align: center; margin: 0 0 1.5rem; }
.login-foot a { color: var(--muted, #6b7a72); font-weight: 600; }

/* teacher account pages (log in, sign up, reset) share the login card */
.login-form .form-title { margin: 0 0 .4rem; font-size: 1.5rem; }
.login-form p { margin: .3rem 0; }
.login-form .form-links { margin-top: .9rem; text-align: center; font-size: .95rem; }
.login-form .form-links a, .login-form .small a { color: var(--muted, #6b7a72); font-weight: 600; }
.login-form input[readonly] { background: #f1f4f2; color: var(--muted, #6b7a72); }
.login-form .check-line { display: flex; gap: .6rem; align-items: flex-start; font-weight: 500; font-size: 1rem; line-height: 1.35; margin-top: .9rem; }
.login-form .check-line input { width: 1.3rem; height: 1.3rem; margin-top: .15rem; flex: none; accent-color: var(--green); }
.login-form .small { font-size: .9rem; }
.signup-form { max-width: 480px; }
