/* Study Drive (student app): tile, subject / topic / item pages and the gallery. See js/study-drive.js */

/* ---- the home tile (after Weekly Toppers) ---- */
.tile-sd { background: linear-gradient(160deg, #8cc63f, #5f9b1e); color: #fff; border-color: #4d8216; } /* lime green: not used by any other tile */
.tile-sd .tile-icon { color: #5f9b1e; background: #fff; border-radius: 50%; width: 84px; height: 84px; display: inline-flex; align-items: center; justify-content: center; }
.tile-sd[hidden] { display: none; }
[data-theme="fun"] .tile-sd { background: #7fbf2f; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
[data-theme="fun"] .tile-sd .tile-icon i { color: #5f9b1e; text-shadow: none; }

/* ---- the light green look of the Study Drive pages (body.sd-mode, like the Listening Lab's lilac): header, background and lines are green, so it is never
   mistaken for eHomework. Change the variables here to try another look. ---- */
html body.sd-mode {
  --bg: #eef8dc; --card: #ffffff; --line: #cfe5a6; --brand: #7cb82f; --brand-dark: #4f8f1a; --muted: #5c7a3a;
  --header: #6aa825; --header-dark: #4f8f1a;
  background-color: #eef8dc; background-image: none;
}
body.sd-mode .sd-page, body.sd-mode .hw-summary { background: transparent; border: 0; box-shadow: none; padding: 4px 0 24px; max-width: 640px; margin: 0 auto; }
body.sd-mode .top-mini { position: sticky; top: 0; z-index: 60; }
body.sd-mode .top-mini .mini-stars { display: none; }
.sd-page[hidden] { display: none; }
.sd-loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 30px 0; }
.sd-empty { text-align: center; padding: 30px 12px; color: var(--muted); }
.sd-empty p { font-weight: 700; color: var(--ink); margin: 0 0 6px; }
.sd-btn {
  display: inline-block; font: inherit; font-weight: 800; font-size: 1.05rem; text-align: center; text-decoration: none; cursor: pointer;
  padding: 12px 20px; border-radius: 14px; border: 2px solid var(--brand-dark); background: var(--brand-dark); color: #fff;
}
.sd-btn:active { transform: scale(.98); }

/* subjects */
.sd-subjects { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sd-subject {
  font: inherit; text-align: left; cursor: pointer; padding: 16px 14px; min-height: 128px; border-radius: 16px; border: 0; color: #fff;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
}
.sd-folder { width: 30px; height: 25px; flex: none; display: block; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .18)); }
.sd-folder.big { width: 52px; height: 42px; }
.sd-subject-name { font-size: 1.2rem; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.sd-subject small { opacity: .9; font-weight: 600; }
.sd-subject:active { transform: scale(.97); }
.sd-subject { background: linear-gradient(160deg, #d6efab, #b3db7a); color: #2c5a0a; } /* every subject card is the same LIGHT green (lighter than the header) with dark green writing */
.sd-subject small { color: #4a7a1c; opacity: 1; }
[data-theme="fun"] .sd-subject { border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 4px 0 var(--shadow, rgba(0, 0, 0, .25)); }

/* chapters and topics */
.sd-chapter { margin-bottom: 16px; }
.sd-chapter h3 { margin: 0 0 8px; font-size: 1.15rem; font-weight: 900; color: #3f7413; display: flex; align-items: center; gap: 10px; }
.sd-chapter h3 span { min-width: 0; overflow-wrap: anywhere; }
/* the topics sit inside their chapter folder, joined by a guide line like a folder tree */
.sd-tree { margin-left: 15px; padding-left: 14px; border-left: 3px solid #b9d98a; }
.sd-topic {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; font: inherit; font-weight: 700; text-align: left; cursor: pointer;
  padding: 14px 14px; margin-bottom: 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink);
}
.sd-topic > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sd-topic small { flex: none; color: var(--muted); font-weight: 600; }
.sd-topic:active { border-color: var(--brand); }
[data-theme="fun"] .sd-topic { border: 3px solid var(--ink); border-radius: 16px; }

/* the items of a topic */
.sd-crumb { margin: 0 0 10px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.sd-items { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.sd-item {
  width: 100%; display: flex; align-items: center; gap: 12px; font: inherit; text-align: left; cursor: pointer;
  padding: 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink);
}
.sd-item:active { border-color: var(--brand); }
.sd-thumb { flex: none; width: 60px; height: 60px; border-radius: 10px; overflow: hidden; background: #f3f6f4; display: flex; align-items: center; justify-content: center; }
.sd-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sd-thumb .sd-doc { width: 38px; height: 48px; }
.sd-thumb .sd-play { width: 40px; height: 40px; }
.sd-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sd-item-text b { overflow-wrap: anywhere; }
.sd-item-text small { color: var(--muted); font-weight: 600; margin-top: 2px; }
.sd-zip { display: block; width: 100%; }
.sd-note { margin: 8px 2px 0; color: var(--muted); font-size: .85rem; text-align: center; }
[data-theme="fun"] .sd-item { border: 3px solid var(--ink); border-radius: 16px; }

/* ---- the gallery: a full-screen dark popup with previous / next, the title at the bottom ---- */
body.sdg-open { overflow: hidden; }
.sdg { position: fixed; inset: 0; z-index: 2000; background: #101214; color: #fff; display: flex; flex-direction: column; }
.sdg[hidden] { display: none; }
.sdg-top { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: rgba(255, 255, 255, .06); }
.sdg-close { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: 20px; cursor: pointer; }
.sdg-count { flex: 1; font-weight: 700; opacity: .85; }
.sdg-actions { flex: none; display: flex; gap: 8px; }
.sdg-act {
  font: inherit; font-weight: 800; font-size: .95rem; cursor: pointer; text-decoration: none; color: #fff; padding: 9px 14px; border-radius: 999px;
  border: 0; background: #4f8f1a; display: inline-block;
}
.sdg-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.sdg-slide { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.sdg-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 44px; height: 64px; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .45); color: #fff; font-size: 34px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.sdg-nav.prev { left: 0; border-radius: 0 12px 12px 0; }
.sdg-nav.next { right: 0; border-radius: 12px 0 0 12px; }
.sdg-nav:disabled { opacity: .25; cursor: default; }
.sdg-cap { flex: none; padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px)); text-align: center; font-weight: 700; font-size: 1.05rem; background: rgba(255, 255, 255, .06); overflow-wrap: anywhere; }

/* a picture: zoom happens inside this box (pinch, double-tap, drag) */
.sdg-imgbox { position: relative; width: 100%; height: 100%; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: pan-y; user-select: none; }
.sdg-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; transform-origin: center center; -webkit-user-drag: none; }
.sdg-img[hidden] { display: none; }
.sdg-loading { display: flex; align-items: center; justify-content: center; gap: 10px; opacity: .8; padding: 20px; text-align: center; }

/* a file: the icon in the middle with its name and a Download button */
/* a PDF: the pages one under the other, scrolling, with a zoom bar under them */
.sdg-pdf { width: 100%; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.sdg-pdf-scroll { flex: 1; min-height: 0; overflow: auto; background: #2b2e33; -webkit-overflow-scrolling: touch; }
.sdg-pdf-pages { width: 100%; padding: 6px 0; display: flex; flex-direction: column; gap: 6px; }
.sdg-pdf-canvas { display: block; width: 100%; height: auto; background: #fff; }
.sdg-pdf-bar { flex: none; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px; background: rgba(255, 255, 255, .06); font-weight: 700; font-size: .9rem; }
.sdg-zoom { width: 40px; height: 34px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .16); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.sdg-file { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 20px; max-width: 100%; }
.sdg-file b { overflow-wrap: anywhere; font-size: 1.1rem; }
.sdg-file small { opacity: .75; font-weight: 600; }
.sd-doc.big { width: 130px; height: 163px; }

/* a video: the YouTube thumbnail with a Play button; the player replaces it when played */
.sdg-video { width: 100%; max-width: 900px; aspect-ratio: 16 / 9; position: relative; background: #000; }
.sdg-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.sdg-thumb { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; cursor: pointer; background-size: cover; background-position: center; display: flex; align-items: center; justify-content: center; }
.sdg-thumb .sd-play { width: 72px; height: 72px; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5)); }
.sdg-link .sd-play.big { width: 110px; height: 110px; }
.sdg-url { max-width: 100%; overflow-wrap: anywhere; opacity: .85; font-weight: 600; margin-bottom: 10px; }
.sdg-link .sd-btn { background: #0ea5a4; border-color: #0ea5a4; }

/* the chapters of a subject (chapters only), and a chapter's files grouped by topic */
.sd-chapters { display: grid; gap: 10px; }
.sd-group { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; font-size: 1rem; font-weight: 800; color: #2f5d1a; }
.sd-group .sd-folder { width: 26px; height: 22px; flex: none; }

/* the gallery's top bar: the topic (or the chapter) of the file shown, then the counter */
.sdg-topic { flex: 1; min-width: 0; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sdg-top .sdg-count { flex: none; }

/* while the gallery is open the page itself never zooms: a pinch only zooms the picture (or the PDF) inside its box */
.sdg { touch-action: pan-x pan-y; }
.sdg .sdg-imgbox { touch-action: none; }

/* turning pages like a book: every page is a box filling the stage; the turning one swings over its left edge (3D), the one under it is shaded */
.sdg-stage { perspective: 1800px; overflow: hidden; }
.sdg-slide { position: absolute; inset: 0; background: #101214; }
.sdg-slide.turning { z-index: 2; transform-origin: left center; backface-visibility: hidden; box-shadow: 0 0 34px rgba(0, 0, 0, .6); will-change: transform; }
.sdg-slide.turning::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to left, rgba(255, 255, 255, .08), rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, .18)); }
.sdg-slide.under { z-index: 1; }
.sdg-shade { position: absolute; inset: 0; z-index: 4; background: #000; pointer-events: none; opacity: 0; }

/* the subject in small letters above the chapter title in the header (a chapter's files page); nothing outside Study Drive */
.sd-head-sub { display: none; }
body.sd-mode .top-mini .sd-head-sub:not(:empty) { display: block; font-size: .78rem; font-weight: 700; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 1px; }

/* a video that is not on YouTube: a normal video player */
.sdg-videofile { width: 100%; height: 100%; display: block; background: #000; }
