/*
 * board.css : the layout and the pieces of the board
 *
 * Colours and shapes come from theme/theme.css (the var(--something) bits).
 * To change a colour, change it there, not here.
 */

/* ---------- Page: fixed to the screen, like an app ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;   /* no rubber-band bounce */
  touch-action: manipulation;  /* no double-tap zoom */
}

body {
  position: fixed;
  inset: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper) radial-gradient(var(--paper-dots) 1.2px, transparent 1.3px) 0 0 / 22px 22px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */

.top {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1rem;
  padding: max(.5rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) .4rem max(1.25rem, env(safe-area-inset-left));
}

.top h1 { margin: 0; font-size: 1.6rem; font-weight: 900; letter-spacing: -.01em; }
.today { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--ink-soft); }

/* ---------- The two sides ---------- */

.sides {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;   /* landscape: side by side */
  border-top: 3px dashed var(--line);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.loading { margin: auto; font-size: 1.3rem; color: var(--ink-soft); grid-column: 1 / -1; text-align: center; }

.side {
  position: relative;
  min-height: 0;
  overflow-y: auto;                 /* too much on one side? that side scrolls */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  padding: .85rem 1.25rem;
  background: var(--kid-tint);
  transition: background-color .5s, color .5s;
}

.side + .side { border-left: 3px dashed var(--line); }

/* Name, counter, stamp */
.side-head { display: flex; align-items: center; gap: .75rem; min-height: 2.6rem; flex-wrap: wrap; }
.kid-name {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1;
  text-decoration: underline var(--kid) .3rem;
  text-underline-offset: .35rem;
}
.count { font-size: 1.2rem; font-weight: 800; color: var(--ink-soft); }

.stamp {
  display: none;
  margin-left: auto;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: .04em;
  border: 4px solid #fff;
  border-radius: 14px;
  padding: .15rem .9rem;
  transform: rotate(-4deg);
}

/* ---------- Morning must-dos ---------- */

.mustdos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
  gap: .65rem;
}

.mustdo {
  position: relative;
  border: 0;
  min-height: 4.75rem;
  padding: .55rem .6rem;
  border-radius: var(--card-corners);
  background: var(--kid-note);
  box-shadow: 0 6px 14px #0000001f, 0 1px 0 #0000001a;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: .2rem;
  text-align: left;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.1;
  transform: rotate(calc(var(--tilt) * -1));
  transition: background-color .2s, transform .15s;
}
.mustdo:nth-child(even) { transform: rotate(var(--tilt)); }
.mustdo:active { transform: scale(.96); }
.mustdo .ico { font-size: 1.7rem; line-height: 1; }
.mustdo.done { background: var(--done-card); }
.mustdo.done::after {
  content: "✔";
  position: absolute;
  top: .35rem;
  right: .55rem;
  font-size: 1.5rem;
  color: var(--tick);
}

/* ---------- Homework heading + Add button ---------- */

.hw-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.hw-head h3 { margin: 0; font-size: 1.3rem; font-weight: 900; }

.add-btn {
  min-height: 3.5rem;
  padding: 0 1.3rem;
  border: 0;
  border-radius: 18px;
  background: var(--ink);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow: 0 4px 0 #00000033;
}
.add-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #00000033; }

/* ---------- Max: To do / Done columns ---------- */

.columns {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.col {
  min-width: 0;
  min-height: 9rem;
  border: 3px dashed var(--line);
  border-radius: 20px;
  padding: .5rem .6rem .7rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: background-color .15s, border-color .15s;
}
.col-done { border-color: #8fcf8a; background: #e3f6df88; }
.col.over { background: #ffffffaa; border-color: var(--ink-soft); border-style: solid; }

.col h4 {
  margin: 0;
  display: flex;
  justify-content: space-between;
  font-size: .95rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-soft);
}
.col-done h4 { color: #3d8a3a; }

.empty { margin: auto; padding: .5rem; text-align: center; font-size: 1.05rem; font-weight: 700; color: var(--ink-soft); }

.bb-status {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.sample-tag {
  display: inline-block;
  margin-left: .5rem;
  padding: .05rem .5rem;
  border: 2px solid currentColor;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  vertical-align: .1em;
}

/* ---------- Homework sticky notes ---------- */

.card {
  position: relative;
  flex: none;
  border-radius: var(--card-corners);
  background: var(--card-bg, var(--card-other));
  color: var(--ink);
  box-shadow: 0 6px 14px #0000001f, 0 1px 0 #0000001a;
  transform: rotate(var(--tilt));
  transition: transform .15s, opacity .15s;
  touch-action: none;   /* a finger on a card drags it; scroll from the gaps around cards */
}
.card:nth-child(odd) { transform: rotate(calc(var(--tilt) * -1.2)); }
.card.done { background: var(--done-card); }

.card-btn {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  width: 100%;
  min-height: 3.5rem;
  padding: .5rem .75rem .55rem;
  border: 0;
  background: none;
  text-align: left;
}
.card.own .card-btn { padding-right: 3rem; } /* room for the ✕ */

.card-top { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.card .tag { font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .65; }
.card .t { font-size: 1.1rem; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.card.done .t::before { content: "✔ "; color: var(--tick); }
.card .src { font-size: .8rem; opacity: .7; }

.badge {
  flex: none;
  padding: .05rem .45rem;
  border-radius: 99px;
  background: #fff;
  color: var(--tick);
  font-size: .75rem;
  font-weight: 900;
  white-space: nowrap;
}

.card-x {
  position: absolute;
  top: 0;
  right: 0;
  width: 2.75rem;
  height: 2.75rem;   /* 44px: small but still easy to hit */
  border: 0;
  border-radius: 0 6px 0 14px;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 900;
  opacity: .55;
}
.card-x:active { opacity: 1; background: #00000014; }

/* "Remove this card?" */
.card.confirming { transform: none; padding: .55rem .65rem; touch-action: manipulation; }
.confirm-q { margin: 0 0 .45rem; font-size: 1.05rem; font-weight: 900; }
.confirm-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.confirm-row button {
  flex: 1 1 5rem;
  min-height: 3.5rem;
  border: 0;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 900;
}
.confirm-yes { background: var(--ink); color: #fff; }
.confirm-no { background: #fff; }

/* While dragging */
.card.lifted { opacity: .3; }
.ghost {
  position: fixed;
  z-index: 50;
  margin: 0;
  pointer-events: none;
  transition: none;
  box-shadow: 0 18px 32px #00000040;
}
body.dragging, body.dragging * { cursor: grabbing; }

/* ---------- Margot: the big "Homework done" card ---------- */

.simple { display: flex; flex-direction: column; gap: .75rem; }

.big-done {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  min-height: 5rem;
  padding: .75rem 1.25rem;
  border: 0;
  border-radius: var(--card-corners);
  background: var(--card-homework);
  color: var(--ink);
  box-shadow: 0 6px 14px #0000001f, 0 1px 0 #0000001a;
  text-align: left;
  transform: rotate(calc(var(--tilt) * -.6));
  transition: background-color .2s, transform .15s;
}
.big-done:active { transform: scale(.98); }
.big-done.done { background: var(--done-card); }
.big-ico { font-size: 2.3rem; line-height: 1; }
.big-done.done .big-ico { color: var(--tick); font-weight: 900; }
.big-words { display: flex; flex-direction: column; gap: .1rem; }
.big-title { font-size: 1.5rem; font-weight: 900; line-height: 1.1; }
.big-sub { font-size: .95rem; font-weight: 700; opacity: .7; }

.stickies {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: .65rem;
}
.stickies .card { touch-action: manipulation; } /* no dragging here, so let it scroll */

/* ---------- ALL DONE: the whole side turns green ---------- */

.side.alldone { background: var(--alldone); color: #fff; }
.side.alldone .count,
.side.alldone .bb-status,
.side.alldone .empty,
.side.alldone .col h4 { color: #fff; }
.side.alldone .kid-name { text-decoration-color: #ffffff99; }
.side.alldone .stamp { display: block; }
.side.alldone.just-done .stamp { animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1); }

.side.alldone .mustdo { background: #ffffff33; color: #fff; box-shadow: none; }
.side.alldone .mustdo.done::after { color: #fff; }

/* Homework still works on a green side, and stays easy to read */
.side.alldone .col { border-color: #ffffffaa; background: #ffffff1f; }
.side.alldone .col.over { background: #ffffff55; border-color: #fff; }
.side.alldone .add-btn { background: #fff; color: var(--ink); }

@keyframes stamp {
  from { transform: rotate(-14deg) scale(2); opacity: 0; }
  to   { transform: rotate(-4deg) scale(1); opacity: 1; }
}

/* ---------- Kitchen paper strip ---------- */

.paper {
  flex: none;
  border-top: 3px dashed var(--line);
  background: var(--strip);
  color: var(--ink-soft);
  font-size: 1rem;
  padding: .55rem max(1.25rem, env(safe-area-inset-right)) max(.55rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
}

/* ---------- The "+ Add a card" box ---------- */

.add-dialog {
  width: min(34rem, calc(100vw - 2rem));
  margin: 6vh auto auto;     /* near the top, so the keyboard doesn't cover it */
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 20px 50px #00000055;
}
.add-dialog[open] { display: block; }
.add-dialog::backdrop { background: #2b262266; }
/* For browsers without showModal() */
.add-dialog[open]:not(:modal) { position: fixed; inset: 0; z-index: 100; }

#add-form { padding: 1.25rem 1.4rem 1.4rem; display: flex; flex-direction: column; gap: .8rem; }
#add-form h2 { margin: 0; font-size: 1.6rem; font-weight: 900; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  min-height: 3.5rem;
  padding: 0 1.1rem;
  border: 3px solid transparent;
  border-radius: 99px;
  background: var(--card-bg, var(--card-other));
  font-size: 1.1rem;
  font-weight: 800;
}
.chip.on { border-color: var(--ink); }
.chip.on::before { content: "✔ "; }

.add-label { font-size: 1.1rem; font-weight: 800; }
.add-input {
  width: 100%;
  min-height: 3.5rem;
  padding: 0 1rem;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.25rem;   /* 16px or more, so iPad doesn't zoom in */
  -webkit-user-select: text;
  user-select: text;
}
.add-input:focus { outline: none; border-color: var(--ink); }

.dialog-buttons { display: flex; gap: .75rem; margin-top: .25rem; }
.dialog-buttons button {
  flex: 1;
  min-height: 3.75rem;
  border: 0;
  border-radius: 18px;
  font-size: 1.3rem;
  font-weight: 900;
}
.btn-cancel { background: #fff; border: 3px solid var(--line) !important; }
.btn-add { background: var(--ink); color: #fff; box-shadow: 0 4px 0 #00000033; }
.btn-add:disabled { background: #d9cdb8; color: var(--ink-soft); box-shadow: none; cursor: default; }

/* ---------- Different screens ---------- */

/* iPad portrait: Max on top, Margot below. Each side takes the room it needs. */
@media (orientation: portrait) {
  .sides { display: flex; flex-direction: column; }
  .side { flex: 1 1 auto; }
  .side + .side { border-left: 0; border-top: 3px dashed var(--line); }
}

/* Phones (and very short screens): the middle part scrolls */
@media (max-width: 600px), (max-height: 520px) {
  .sides { display: block; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .side { overflow: visible; }
  .side + .side { border-left: 0; border-top: 3px dashed var(--line); }
  .side { padding: .75rem 1rem; }
  .kid-name { font-size: 1.8rem; }
  .hw-head h3 { font-size: 1.15rem; }
  .add-btn { padding: 0 1rem; font-size: 1.05rem; }
  .columns { gap: .5rem; }
  .col { padding: .45rem .4rem .6rem; }
  .card-btn { padding: .45rem .55rem; }
  .card .t { font-size: 1rem; }
}

/* Big kitchen screen: everything a bit bigger, to read from across the room */
@media (min-width: 1600px) and (min-height: 900px) {
  html { font-size: 20px; }
}
