/* ==========================================================================
   PNLE-REVIEW — Study Cards page
   Category chips, deck tiles, card list, quote art and the flip-card dialog.
   ========================================================================== */

/* Fit-to-screen rows: top bar · chips · content */
.main--cards { --fit-rows: auto auto 1fr; }


/* Category tones (deck tiles, row icons, flashcards) */
.deck--blue   { --deck-bg: var(--tint-blue);   --deck-fg: var(--blue);   --deck-border: #d6e3fa; }
.deck--purple { --deck-bg: var(--tint-purple); --deck-fg: #8a63d2;       --deck-border: #e3daf7; }
.deck--sky    { --deck-bg: var(--tint-sky);    --deck-fg: #3a8fc4;       --deck-border: #d3e6f5; }
.deck--peach  { --deck-bg: var(--tint-peach);  --deck-fg: var(--orange); --deck-border: #f7e2c3; }
:root[data-theme="dark"] [class*="deck--"] { --deck-border: var(--card-border); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [class*="deck--"] { --deck-border: var(--card-border); }
}

/* ============================== Filters ============================== */
.cd-filters { padding: 0 4px; }
.cd-filters .chips { margin-bottom: 0; }
.cd-filters .chip { display: inline-flex; align-items: center; gap: 6px; }
.cd-filters .chip:not(.is-active) { background: var(--card-solid); border-color: var(--card-border); }

/* ============================== Grid ============================== */
.cd-grid {
  display: grid;
  grid-template-columns: minmax(0, 3.3fr) minmax(220px, 1fr);
  gap: 14px;
  min-height: 0;
}
.cd-main { display: flex; flex-direction: column; gap: 14px; min-height: 0; padding: 16px 18px; }
.cd-toolbar { display: flex; gap: 10px; }
.cd-search { flex: 1; width: auto; height: 36px; }

/* ============================== Decks ============================== */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.deck {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  column-gap: 12px;
  min-height: 118px;
  padding: 16px;
  text-align: left;
  background: var(--deck-bg);
  border: 1px solid var(--deck-border);
  border-radius: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.deck:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.deck.is-active { box-shadow: 0 0 0 2px var(--primary), var(--shadow); }
.deck__icon { grid-row: 1 / 3; color: var(--deck-fg); }
.deck__icon .icon { width: 28px; height: 28px; stroke-width: 1.7; }
.deck__text strong { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); }
.deck__text span { display: block; margin-top: 6px; font-size: 10.5px; line-height: 1.5; color: var(--muted); }
.deck__count { grid-column: 2; align-self: end; margin-top: 14px; font-size: 11px; font-weight: 500; color: var(--text-2); }

/* ============================== Card list ============================== */
.card-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 12px 14px 8px;
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}
.card-panel .card__head { margin-bottom: 6px; }
.card-panel .card__title { font-size: 13.5px; }
.card-panel .btn .icon { width: 14px; height: 14px; }
.card-panel .btn:disabled { opacity: 0.45; cursor: not-allowed; }

.card-list { flex: 1; min-height: 0; max-height: 420px; overflow-y: auto; scrollbar-width: thin; }
.is-fit .card-list { max-height: none; }
.card-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1.3fr) minmax(0, 0.8fr) minmax(0, 1.1fr) 64px auto;
  align-items: center;
  gap: 12px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
}
.card-list li:last-child { border-bottom: 0; }
.card-row__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--deck-fg);
  background: var(--deck-bg);
  border-radius: 8px;
}
.card-row__icon .icon { width: 16px; height: 16px; }
.card-row__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
}
.card-row__title:hover { color: var(--primary-600); }
.card-row__cat { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-row__value { font-size: 11.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bookmark { width: 28px; height: 28px; color: var(--muted); }
.bookmark .icon { width: 15px; height: 15px; }
.bookmark.is-on { color: var(--primary); }
.bookmark.is-on .icon { fill: currentColor; }
.card-list__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 30px 10px;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}
.card-list__empty .icon { width: 22px; height: 22px; }

/* ============================== Quote ============================== */
.cd-quote {
  min-height: 260px;
  padding: 0;
  background:
    url("../../assests/images/flowers-corner.svg") right -8px top 6px / 92px auto no-repeat,
    linear-gradient(180deg, #eef0fb 0%, #e1e8f7 100%);
}
.cd-quote::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  aspect-ratio: 280 / 340;
  background: url("../../assests/images/cards-quote.svg") center bottom / 100% auto no-repeat;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%);
          mask-image: linear-gradient(180deg, transparent 0%, #000 30%);
  pointer-events: none;
}
.cd-quote__text {
  position: absolute;
  z-index: 1;
  top: 54px;
  left: 26px;
  right: 18px;
  font-size: 21px;
  line-height: 1.4;
  color: #2a3f73;   /* the art stays light in dark mode */
  transform: rotate(-4deg);
}
.cd-quote__text .note-heart { display: inline-block; vertical-align: middle; }

/* ============================== Flashcard dialog ============================== */
.modal--flash { width: min(560px, calc(100vw - 32px)); }
.flash {
  position: relative;
  display: block;
  width: 100%;
  height: 250px;
  margin-top: 16px;
  padding: 0;
  background: none;
  transform: perspective(1200px) rotateY(0);
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(.2, .8, .2, 1);
}
.flash.is-flipped { transform: perspective(1200px) rotateY(180deg); }
.flash:focus-visible { box-shadow: none; outline: none; }
.flash:focus-visible .flash__face { box-shadow: var(--focus); }
.flash__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 32px;
  text-align: center;
  border-radius: 16px;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
}
.flash__front { background: var(--deck-bg); border: 1px solid var(--deck-border); }
.flash__front strong { font-size: 22px; font-weight: 600; color: var(--text); }
.flash__front small { font-size: 11.5px; color: var(--muted); }
.flash__icon { color: var(--deck-fg); }
.flash__icon .icon { width: 34px; height: 34px; stroke-width: 1.6; }
.flash__back {
  transform: rotateY(180deg);
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  box-shadow: inset 0 0 0 4px var(--deck-bg);
}
.flash__back strong { font-size: 20px; font-weight: 600; color: var(--primary-600); }
.flash__back span { font-size: 13px; line-height: 1.65; color: var(--text-2); }
.flash-actions { align-items: center; }
.flash-actions__hint { flex: 1; font-size: 10.5px; text-align: center; color: var(--muted); }
.flash-actions .btn .icon { width: 14px; height: 14px; }
.flash-actions .btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ============================== Breakpoints ============================== */
@media (max-width: 1320px) {
  .deck-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .cd-grid { grid-template-columns: minmax(0, 1fr); }
  .cd-quote { display: none; }
}
@media (max-width: 720px) {
  .deck-grid { grid-template-columns: minmax(0, 1fr); }
  .card-row { grid-template-columns: 30px minmax(0, 1fr) 64px auto; }
  .card-row__cat, .card-row__value { display: none; }
  .flash-actions__hint { display: none; }
}

/* Dark mode: keep the watercolor art, but on a deep wash so the card doesn't glare */
:root[data-theme="dark"] .cd-quote { background: url("../../assests/images/flowers-corner.svg") right -8px top 6px / 92px auto no-repeat, linear-gradient(180deg, #27325e 0%, #1c2647 100%); }
:root[data-theme="dark"] .cd-quote::before { opacity: 0.5; }
:root[data-theme="dark"] .cd-quote__text { color: var(--script) !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cd-quote { background: url("../../assests/images/flowers-corner.svg") right -8px top 6px / 92px auto no-repeat, linear-gradient(180deg, #27325e 0%, #1c2647 100%); }
  :root:not([data-theme="light"]) .cd-quote::before { opacity: 0.5; }
  :root:not([data-theme="light"]) .cd-quote__text { color: var(--script) !important; }
}

/* ============================== Your cards ============================== */
.cd-toolbar .btn { gap: 7px; flex: none; }
.cd-toolbar .btn .icon { width: 15px; height: 15px; }
.card-panel__tools { display: flex; align-items: center; gap: 8px; }
.card-row__tools { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.card-row__tools .icon-btn .icon { width: 15px; height: 15px; }
.mine-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 9.5px;
  font-weight: 600;
  vertical-align: 1px;
  color: #8a63d2;
  background: var(--tone-purple);
  border-radius: 999px;
}
.card-hidden-note { margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.card-hidden-note .link-more { display: inline; padding: 0; font-size: 11.5px; }

.modal--card-form { width: min(480px, calc(100vw - 32px)); }
.card-form { display: flex; flex-direction: column; gap: 12px; }
.card-form .modal__head { margin-bottom: 4px; }
.card-form textarea {
  padding: 9px 12px;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  outline: 0;
  resize: vertical;
}
.card-form textarea:focus { border-color: var(--primary); box-shadow: var(--focus); }
.card-form__spacer { flex: 1; }
.card-form__delete { gap: 6px; color: var(--red); }
.card-form__delete .icon { width: 14px; height: 14px; }
.card-form .modal__actions { margin-top: 4px; }
.gen__counts--3 .segmented { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Phones: toolbar wraps so "Add card" stays on screen */
@media (max-width: 720px) {
  .cd-toolbar { flex-wrap: wrap; }
  .cd-search { flex-basis: 100%; order: -1; }
  .cd-toolbar .btn { flex: 1 1 auto; justify-content: center; }
  .card-panel .card__head { flex-wrap: wrap; gap: 8px; }
}
@media (max-width: 480px) {
  .card-row { grid-template-columns: 30px minmax(0, 1fr) 64px; }
  .card-row > .btn--soft { display: none; }   /* tapping the name opens the card */
}
