/* =========================================================================
   Consignment 101 - the look.
   A friendly "on the road" style: every part of the app is a colourful
   stop on your route. Big text, big buttons, plain words.
   All fonts are bundled. Nothing is loaded from other websites.
   ========================================================================= */

@font-face { font-family: 'Nunito'; src: url('fonts/Nunito-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('fonts/Nunito-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('fonts/Nunito-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('fonts/Fredoka-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --ink: #1f2a37;
  --ink-soft: #4b5563;
  --paper: #fffaf1;
  --card: #ffffff;
  --line: #eadfcd;
  --road: #3d4451;
  --accent: #e8553d;
  --tint: #fde6e1;

  /* One colour for each stop on the route. */
  --learn: #e39400;   --learn-tint: #fff1cf;
  --deals: #2f6fde;   --deals-tint: #e3edff;
  --goods: #17925f;   --goods-tint: #daf3e7;
  --markup: #8a4fd8;  --markup-tint: #efe6fc;
  --money: #e0472f;   --money-tint: #fde4de;
  --convert: #0a8e9a; --convert-tint: #d9f3f5;

  --danger: #c62828;
  --radius: 20px;
  --shadow: 0 2px 0 rgba(31, 42, 55, .08), 0 8px 24px rgba(31, 42, 55, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Nunito', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 20px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  /* A faint dotted "road map" paper. */
  background-image: radial-gradient(rgba(61, 68, 81, .07) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .display { font-family: 'Fredoka', 'Nunito', sans-serif; font-weight: 600; letter-spacing: .2px; }
h1 { font-size: 32px; line-height: 1.15; margin: 0 0 8px; }
h2 { font-size: 26px; line-height: 1.2; margin: 22px 0 10px; }
h3 { font-size: 22px; margin: 16px 0 8px; }
p { margin: 0 0 14px; }
a { color: inherit; }

.sr { position: absolute; left: -9999px; }

/* Section colours: set on <body data-stop="..."> */
body[data-stop="learn"]   { --accent: var(--learn);   --tint: var(--learn-tint); }
body[data-stop="deals"]   { --accent: var(--deals);   --tint: var(--deals-tint); }
body[data-stop="goods"]   { --accent: var(--goods);   --tint: var(--goods-tint); }
body[data-stop="markup"]  { --accent: var(--markup);  --tint: var(--markup-tint); }
body[data-stop="money"]   { --accent: var(--money);   --tint: var(--money-tint); }
body[data-stop="convert"] { --accent: var(--convert); --tint: var(--convert-tint); }

/* ------------------------------ Top bar ------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: 66px;
  padding: calc(env(safe-area-inset-top) + 8px) 14px 8px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.topbar h1 { font-size: 25px; margin: 0; flex: 1; color: #fff; }
.topbar .emoji { font-size: 28px; }
.back {
  min-height: 48px; min-width: 48px; padding: 0 14px 0 8px;
  border: 0; border-radius: 14px;
  background: rgba(255, 255, 255, .2); color: #fff;
  font: 700 19px 'Nunito', sans-serif;
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
}
.back:active { background: rgba(255, 255, 255, .35); }

main { max-width: 860px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 110px); }

/* ------------------------------ Home ------------------------------ */
.hero {
  position: relative; overflow: hidden;
  border-radius: 26px; margin: 4px 0 18px;
  background: linear-gradient(180deg, #ffd88a 0%, #ffe9bd 100%);
  box-shadow: var(--shadow);
}
.hero svg { display: block; width: 100%; height: auto; }
.hero .greet {
  padding: 18px 20px 0;
  font-family: 'Fredoka', sans-serif; font-size: 28px; line-height: 1.15; color: #3a2a12;
}
.hero svg { margin-top: 4px; }
.hero .greet small { display: block; font-family: 'Nunito', sans-serif; font-size: 18px; font-weight: 700; color: #5b4423; margin-top: 4px; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 18px; }
.stat {
  flex: 1 1 150px; background: var(--card); border: 2px solid var(--line); border-radius: 18px;
  padding: 10px 14px; text-decoration: none;
}
.stat b { display: block; font-family: 'Fredoka', sans-serif; font-size: 26px; }
.stat span { font-size: 16px; color: var(--ink-soft); }
.stat.warn { border-color: #f3b0a5; background: #fff1ee; }

.route { position: relative; display: grid; gap: 16px; }
/* The dashed road that joins the stops on a phone. */
.route::before {
  content: ''; position: absolute; left: 44px; top: 20px; bottom: 20px; width: 0;
  border-left: 5px dashed rgba(61, 68, 81, .25); z-index: 0;
}
.stop {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 16px;
  min-height: 92px; padding: 14px 16px;
  background: var(--card); color: var(--ink); text-decoration: none;
  border-radius: var(--radius); border: 3px solid var(--c, var(--line));
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.stop:active { transform: scale(.98); }
.stop .badge {
  flex: none; width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; font-size: 30px;
  background: var(--t); border: 3px solid var(--c);
}
.stop .txt { flex: 1; }
.stop .txt b { display: block; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 24px; line-height: 1.15; }
.stop .txt span { display: block; font-size: 17px; color: var(--ink-soft); }
.stop .txt .num {
  display: inline-block; margin-bottom: 4px; font: 700 13px 'Nunito', sans-serif; text-transform: uppercase; letter-spacing: 1px;
  color: var(--c); background: var(--t); border-radius: 999px; padding: 4px 10px;
}
.stop.learn   { --c: var(--learn);   --t: var(--learn-tint); }
.stop.deals   { --c: var(--deals);   --t: var(--deals-tint); }
.stop.goods   { --c: var(--goods);   --t: var(--goods-tint); }
.stop.markup  { --c: var(--markup);  --t: var(--markup-tint); }
.stop.money   { --c: var(--money);   --t: var(--money-tint); }
.stop.convert { --c: var(--convert); --t: var(--convert-tint); }

@media (min-width: 720px) {
  .route { grid-template-columns: 1fr 1fr; }
  .route::before { display: none; }
}

.tip {
  margin: 20px 0 6px; padding: 14px 16px; border-radius: 18px;
  background: #fff; border: 2px dashed var(--line);
}
.tip b { font-family: 'Fredoka', sans-serif; font-weight: 600; }
.footer-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ------------------------------ Cards and forms ------------------------------ */
.card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  margin: 0 0 16px; box-shadow: var(--shadow); border-top: 6px solid var(--accent);
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.card .card-title { display: flex; align-items: center; gap: 10px; }
.card .card-title .emoji { font-size: 28px; }

.field { display: block; margin: 0 0 16px; }
.field > span { display: block; font-weight: 700; font-size: 18px; margin-bottom: 6px; }
.field small { display: block; color: var(--ink-soft); font-size: 16px; margin-top: 4px; }
input[type=text], input[type=date], input[type=number], input:not([type]), select, textarea {
  width: 100%; min-height: 56px;
  font: 400 20px 'Nunito', sans-serif; color: var(--ink);
  padding: 12px 14px; border-radius: 14px;
  border: 2px solid #d6cbb8; background: #fffdf8;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 15px) 50%;
  background-size: 7px 7px; background-repeat: no-repeat; padding-right: 40px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--tint); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.prefix { position: relative; }
.prefix > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-style: normal; font-weight: 700; color: var(--ink-soft); }
.prefix > input { padding-left: 32px; }
.suffix { position: relative; }
.suffix > i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-style: normal; font-weight: 700; color: var(--ink-soft); }
.suffix > input { padding-right: 44px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 58px; padding: 12px 22px; width: 100%;
  border-radius: 16px; border: 3px solid var(--accent);
  background: var(--accent); color: #fff; text-decoration: none;
  font: 700 20px 'Nunito', sans-serif; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .18);
  transition: transform .08s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .18); }
.btn.soft { background: var(--tint); color: var(--ink); border-color: var(--tint); box-shadow: none; }
.btn.line { background: #fff; color: var(--ink); border-color: #d6cbb8; box-shadow: none; }
.btn.danger { background: #fff; color: var(--danger); border-color: #f0c2bd; box-shadow: none; }
.btn.small { min-height: 48px; padding: 8px 14px; font-size: 18px; width: auto; }
.btns { display: grid; gap: 12px; margin: 16px 0; }
.btns.two { grid-template-columns: 1fr 1fr; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; }
.chip {
  min-height: 48px; padding: 8px 16px; border-radius: 999px;
  border: 2px solid #d6cbb8; background: #fff; color: var(--ink);
  font: 700 18px 'Nunito', sans-serif; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.seg { display: flex; background: #efe7d9; padding: 5px; border-radius: 18px; margin: 0 0 16px; gap: 5px; }
.seg button {
  flex: 1; min-height: 50px; border: 0; border-radius: 14px; background: transparent;
  font: 700 19px 'Nunito', sans-serif; color: var(--ink); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: #fff; color: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, .12); }

.result { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.result:last-child { border-bottom: 0; }
.result b { text-align: right; }
.result.big { font-size: 24px; }
.result.big b { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 28px; color: var(--accent); }
.result.bad b, .bad { color: var(--danger) !important; }
.answer { background: var(--tint); border-radius: 16px; padding: 12px 16px; }
.hint { color: var(--ink-soft); }

.info {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--tint); border-radius: 16px; padding: 14px 16px; margin: 0 0 16px;
}
.info .emoji { font-size: 26px; line-height: 1.2; }
.info b { display: block; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 21px; }
.info.warn { background: #fff1ee; border: 2px solid #f3b0a5; }

/* The fee split drawn as a coloured bar. */
.splitbar { display: flex; height: 34px; border-radius: 12px; overflow: hidden; margin: 6px 0 12px; border: 2px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.splitbar div { height: 100%; min-width: 2px; }
.key { display: inline-block; width: 16px; height: 16px; border-radius: 5px; margin-right: 8px; vertical-align: -2px; }

/* ------------------------------ Lists ------------------------------ */
.list { display: grid; gap: 12px; margin: 0 0 16px; }
.item {
  display: block; background: var(--card); border-radius: 18px; padding: 16px;
  box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
  border-left: 8px solid var(--accent);
}
.item .top { display: flex; gap: 10px; align-items: baseline; }
.item .top b { flex: 1; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 23px; line-height: 1.2; }
.item .meta { color: var(--ink-soft); font-size: 17px; }
.item .counts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0; font-size: 18px; }
.item .counts span b { font-size: 21px; }
.item.urgent { border-left-color: var(--danger); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  background: var(--tint); font-weight: 700; font-size: 16px;
}
.pill.urgent { background: #fde1dd; color: #9b1c1c; }
.pill.soon { background: #fff0c9; color: #7a4b00; }
.pill.done { background: #e4f5ea; color: #13623f; }

.lesson { display: flex; gap: 14px; align-items: center; }
.lesson .n {
  flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  font: 600 22px 'Fredoka', sans-serif; background: var(--tint); color: var(--accent); border: 3px solid var(--accent);
}
.lesson .n.done { background: var(--accent); color: #fff; }
.lesson .txt { flex: 1; }
.lesson .txt b { display: block; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 22px; }
.lesson .txt span { color: var(--ink-soft); font-size: 17px; }
.stamp {
  flex: none; transform: rotate(-12deg); border: 3px solid var(--goods); color: var(--goods);
  border-radius: 10px; padding: 2px 8px; font: 700 14px 'Nunito', sans-serif; letter-spacing: 1px;
}
.progress { height: 14px; background: #efe7d9; border-radius: 999px; overflow: hidden; margin: 6px 0 18px; }
.progress div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }

.lesson-body ul { padding-left: 0; list-style: none; margin: 0 0 16px; }
.lesson-body li { position: relative; padding-left: 34px; margin-bottom: 10px; }
.lesson-body li::before { content: ''; position: absolute; left: 6px; top: 9px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }

details.period { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); margin: 0 0 12px; overflow: hidden; }
details.period summary { list-style: none; cursor: pointer; padding: 16px; min-height: 56px; }
details.period summary::-webkit-details-marker { display: none; }
details.period summary b { display: block; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 22px; }
details.period > div { padding: 0 16px 16px; }

.entry { display: block; padding: 12px 0; border-top: 1px dashed var(--line); text-decoration: none; color: var(--ink); }
.entry b { display: block; }

/* ------------------------------ Badges ------------------------------ */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.bdg { text-align: center; background: #fff; border-radius: 18px; padding: 14px 8px; border: 3px solid var(--line); }
.bdg .e { font-size: 38px; display: block; }
.bdg b { display: block; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 18px; }
.bdg span { font-size: 15px; color: var(--ink-soft); }
.bdg.locked { opacity: .45; filter: grayscale(1); }

/* ------------------------------ The paper (agreement) ------------------------------ */
.paper {
  background: #fff; color: #111; border-radius: 6px; padding: 26px 22px;
  border: 1px solid #ddd; box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
  font-family: Georgia, 'Times New Roman', serif; font-size: 18px; line-height: 1.55;
}
.paper h2 { font-family: Georgia, serif; font-size: 20px; text-align: center; text-transform: uppercase; letter-spacing: .5px; margin: 0 0 18px; }
.paper .sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin: 22px 0; }
.paper .sig .ln { border-bottom: 1.5px solid #222; height: 40px; }
.paper .sig b { display: block; font-size: 15px; margin-top: 4px; font-family: 'Nunito', sans-serif; }
.paper .sig div.small { font-size: 15px; white-space: pre-line; }
.paper table { width: 100%; border-collapse: collapse; font-size: 15px; font-family: 'Nunito', sans-serif; }
.paper th, .paper td { border: 1px solid #444; padding: 6px 6px; text-align: center; }
.paper th:first-child, .paper td:first-child { text-align: left; }
.paper .addendum { margin-top: 30px; }
.paper .foot { font-size: 13px; color: #555; margin-top: 18px; font-family: 'Nunito', sans-serif; }
@media (max-width: 520px) { .paper .sigs { grid-template-columns: 1fr; } }

/* ------------------------------ Pop-ups ------------------------------ */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(20, 24, 32, .55);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  width: 100%; max-width: 520px; background: #fff; border-radius: 24px; padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); animation: pop .18s ease-out;
}
.modal h2 { margin-top: 0; }
.modal .btns { margin-bottom: 0; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.toast {
  position: fixed; left: 0; right: 0; margin: 0 auto; bottom: calc(env(safe-area-inset-bottom) + 20px); z-index: 60;
  width: -webkit-fit-content; width: fit-content; max-width: calc(100% - 32px);
  background: var(--road); color: #fff; padding: 14px 20px; border-radius: 18px;
  font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: rise .2s ease-out;
}
.toast.badge-toast { background: #fff; color: var(--ink); border: 3px solid var(--learn); display: flex; gap: 12px; align-items: center; }
.toast.badge-toast .e { font-size: 40px; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.fab {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 30;
  min-height: 64px; padding: 0 24px; border-radius: 999px; border: 0;
  background: var(--accent); color: #fff; font: 700 21px 'Nunito', sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
}

/* "Cha-ching!" coins and confetti */
.burst { position: fixed; pointer-events: none; z-index: 70; font-size: 30px; animation: fly 1s ease-out forwards; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }
.chaching {
  position: fixed; pointer-events: none; z-index: 70; font: 600 30px 'Fredoka', sans-serif; color: var(--goods);
  text-shadow: 0 2px 0 #fff; animation: chaching .9s ease-out forwards;
}
@keyframes chaching { from { transform: translateY(0) scale(.8); opacity: 1; } to { transform: translateY(-70px) scale(1.15); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .burst, .chaching { display: none; }
  .stop, .btn, .modal, .toast { transition: none; animation: none; }
}

/* ------------------------------ Printing ------------------------------ */
@media print {
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  #print-area .paper { box-shadow: none; border: 0; padding: 0; font-size: 12pt; }
  #print-area .addendum { break-before: page; page-break-before: always; }
}
#print-area { display: none; }
