/* the look of MKTB-Frontend's /searchIndex (src/index.css), only what this page uses */
:root {
  --brand: #c2410c;
  --brand-dark: #9a3412;
  --brand-tint: #fdf6f2;
  --ink: #1c1917;
  --ink-soft: #57534e;
  --ink-muted: #a8a29e;
  --surface: #faf9f7;
  --surface-raised: #ffffff;
  --line: #e7e5e4;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgb(28 25 23 / 0.05), 0 4px 16px rgb(28 25 23 / 0.04);
  --radius: 14px;
  --font-sans: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', Consolas, monospace; /* player.css's times */
  /* the player's bar and track (player.css) */
  --line-soft: #ece9e4;
  --radio-line: #d6d3d1;
  --mark: #fde68a;
  color-scheme: light;
}

/* dark: on a phone or tablet set to it (a touch screen up to an ipad pro's
   1366px), and only at night, 12 am to 6 am on the device's clock (.night,
   set by the script in each page's <head>): the same names, dark values.
   laptops, desktops and tvs stay light, and so does the day */
@media (prefers-color-scheme: dark) and (pointer: coarse) and (max-width: 1366px) {
  :root.night {
    color-scheme: dark;
    --brand: #e8692c;
    --brand-dark: #f08a52;
    --brand-tint: #2b1d15;
    --ink: #f2efed;
    --ink-soft: #c9c3be;
    --ink-muted: #8c857f;
    --surface: #141211;
    --surface-raised: #1d1a18;
    --line: #322d2a;
    --danger: #f87171;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --line-soft: #2b2725;
    --radio-line: #57514c;
    --mark: rgb(250 204 21 / 0.28);
  }
}

* { box-sizing: border-box; }
/* `hidden` wins over a class's display (the copied maktaba CSS sets display on most boxes) */
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
body {
  margin: 0;
  background: var(--surface);
  font-family: var(--font-sans);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }
::placeholder { color: var(--ink-muted); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--ink-muted); font-size: 0.9rem; }

.page { max-width: 1040px; margin: 0 auto; padding: 0 16px 64px; }
/* header: a white band across the whole window */
.top {
  position: relative; z-index: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; margin-bottom: 8px;
}
.top::before {
  content: ''; position: absolute; z-index: -1; inset: 0 -100vmax;
  background: var(--surface-raised); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; color: var(--ink); }
.brand:hover { color: var(--ink); text-decoration: none; }
/* the pages, at the far end of the header */
.top-nav { margin-inline-start: auto; display: flex; gap: 4px; }
.top-nav a { font-size: 0.88rem; color: var(--ink-soft); padding: 4px 12px; border-radius: 999px; }
.top-nav a:hover { background: var(--brand-tint); color: var(--brand); text-decoration: none; }
.top-nav a[aria-current="page"] { color: var(--brand); font-weight: 600; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 700; line-height: 1;
}

.index-head { margin: 8px 0 12px; }
.index-head h1 { font-size: 1.6rem; margin: 0 0 2px; }
.index-head p { margin: 0; }
/* after a search (app.js) the title makes way for the answer */
.searched section.index-head { display: none; }
.searched .search { margin-top: 16px; }

/* the search box */
.search { display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-raised);
  padding: 10px 14px; font-size: 1rem; box-shadow: var(--shadow);
}
.search input:focus { outline: none; border-color: var(--brand); }
.search button {
  border: 0; border-radius: 12px; background: var(--brand); color: #fff;
  padding: 0 22px; font-weight: 600;
}
.search button:hover { background: var(--brand-dark); }
.search button:disabled { opacity: 0.5; cursor: default; }

.summary {
  color: var(--ink-soft); font-size: 0.9rem; margin: 12px 0 8px;
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between;
}

/* the results */
.results { display: grid; gap: 10px; margin-top: 12px; }
.summary + .results, #status:not(:empty) + .results { margin-top: 0; }
.card {
  display: grid; grid-template-columns: 176px 1fr; gap: 14px; align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; box-shadow: var(--shadow);
}
/* list: a bigger video beside the words (on a phone it's full width anyway) */
@media (min-width: 601px) {
  .view-list .card { grid-template-columns: min(320px, 50%) 1fr; gap: 16px; }
  /* the wide page leaves room: about as many lines as the video is tall */
  .view-list .text { -webkit-line-clamp: 3; line-clamp: 3; }
}
.card-media { position: relative; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--line); }
.card-media iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* a card playing its chunk (player.js's chunkPlayer): the video, and under it
   only a thin bar of how far into the chunk it is — no buttons, no times. a
   click on the video plays and pauses; a click on the bar jumps there */
.card-media:has(.chunk-player) { aspect-ratio: auto; border-radius: 10px; background: var(--line); }
.card-media .chunk-player { gap: 0; }
.card-media .chunk-player__stage { border-radius: 0; }
.card-media .chunk-player__controls { direction: ltr; gap: 0; }
.card-media .chunk-player__toggle,
.card-media .chunk-player__time { display: none; }
.card-media .chunk-player__bar { height: 5px; display: block; }
.card-media .chunk-player__bar:focus-visible { outline-offset: -2px; border-radius: 0; }
.card-media .chunk-player__bar::-webkit-slider-runnable-track {
  height: 5px; border-radius: 0;
  background: linear-gradient(to right, var(--brand) 0 var(--progress, 0%), var(--line) var(--progress, 0%) 100%);
}
.card-media .chunk-player__bar::-webkit-slider-thumb { width: 0; height: 5px; margin-top: 0; border: 0; box-shadow: none; }
.card-media .chunk-player__bar::-moz-range-track { height: 5px; border-radius: 0; background: var(--line); }
.card-media .chunk-player__bar::-moz-range-progress { height: 5px; border-radius: 0; background: var(--brand); }
.card-media .chunk-player__bar::-moz-range-thumb { width: 0; height: 5px; border: 0; border-radius: 0; }
.thumb { position: absolute; inset: 0; border: 0; padding: 0; background: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.play {
  position: absolute; inset: 0; margin: auto; width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%; background: rgb(0 0 0 / 0.6); color: #fff;
  transition: transform 0.15s, background 0.15s;
}
.thumb:hover .play { transform: scale(1.08); background: var(--brand); }
/* waiting for the model's start (app.js, automontage.js): the play button spins */
.thumb.waiting { cursor: progress; }
.thumb.waiting .play svg { display: none; }
.thumb.waiting .play::after {
  content: ""; width: 46%; height: 46%; box-sizing: border-box; border-radius: 50%;
  border: 2.5px solid rgb(255 255 255 / 0.35); border-top-color: #fff;
  animation: thumb-spin 0.8s linear infinite;
}
@keyframes thumb-spin { to { transform: rotate(360deg); } }

/* a card the smart view's answer already played through (app.js): the
   player's end screen (player.css .chunk-player__end) over its thumbnail,
   in the smart view only */
.watched {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  background: rgb(0 0 0 / 0.68); color: #fff; padding: 6px;
}
#results:not(.view-smart) .watched { display: none; }
#results.view-smart .card-media:has(.watched) :is(.stamp, .play) { display: none; }
.watched__label { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 0.8rem; }
.watched__actions { display: flex; justify-content: center; gap: 6px; }
.watched button {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; white-space: nowrap;
  border-radius: 999px; border: 1.5px solid #fff; background: rgb(20 20 20 / 0.85); color: #fff;
  font: inherit; font-size: 0.72rem; font-weight: 600; line-height: 1.6; cursor: pointer;
}
.watched button:hover { background: rgb(55 55 55 / 0.9); }
.watched svg { flex: none; }
/* a phone: the card is the screen's width, the end screen gets room */
@media (max-width: 600px) {
  .watched { gap: 12px; }
  .watched__label { font-size: 0.95rem; gap: 6px; }
  .watched__actions { gap: 10px; }
  .watched button { font-size: 0.85rem; padding: 6px 16px; gap: 8px; }
}
.stamp {
  position: absolute; bottom: 6px; left: 6px;
  background: rgb(0 0 0 / 0.75); color: #fff;
  font-size: 0.78rem; padding: 0 6px; border-radius: 4px;
}
/* title, then the text, then one quiet line: part · time · date … score */
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; line-height: 1.5; }
.card-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1rem; font-weight: 600; }
.rank {
  flex: none; display: inline-grid; place-items: center; min-width: 22px; height: 22px;
  border-radius: 6px; background: var(--brand-tint); color: var(--brand);
  font-weight: 600; font-size: 0.78rem;
}
.episode { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text {
  margin: 0; color: var(--ink-soft); font-size: 0.9rem;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--ink-muted); }
.card-meta .score { margin-inline-start: auto; }
.score { color: var(--ink-muted); font-size: 0.8rem; }

/* the summary on one side, the view switch on the other */
/* by meaning / by words / both (app.js): radio buttons under the search box —
   a circle before each word, filled with the brand colour on the one picked */
.modes { display: flex; align-items: center; gap: 14px; margin-top: 8px; font-size: 0.8rem; }
.modes-label { color: var(--ink-muted); margin-inline-end: -4px; }
.modes button {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: none; color: var(--ink-muted); padding: 1px 0; font: inherit; cursor: pointer;
  transition: color 0.15s;
}
.modes button[hidden] { display: none; }
.modes button::before {
  content: ""; flex: none; width: 12px; height: 12px; box-sizing: border-box; border-radius: 50%;
  border: 1.5px solid var(--radio-line); background: var(--surface-raised);
  transition: border-color 0.15s, background-color 0.15s;
}
.modes button:hover { color: var(--ink-soft); }
.modes button:hover::before { border-color: #f0a37e; }
.modes button.on { color: var(--ink-soft); }
.modes button.on::before { border-color: #f0a37e; background: #e8733f; box-shadow: inset 0 0 0 2px var(--surface-raised); }
/* the home page, before a search: the choice is part of asking, so it's bigger;
   once there are results (body.searched, app.js) it steps back to the small one */
body:not(.searched) .modes { gap: 20px; margin-top: 14px; font-size: 1rem; }
body:not(.searched) .modes-label { margin-inline-end: -6px; }
body:not(.searched) .modes button { gap: 8px; }
body:not(.searched) .modes button::before { width: 17px; height: 17px; border-width: 2px; }
body:not(.searched) .modes button.on::before { box-shadow: inset 0 0 0 3px var(--surface-raised); }
/* the words a search by words matched, in a result's text */
.text mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 16px; margin: 12px 0 10px;
}
.toolbar #status { flex: 1 1 auto; min-width: 0; }
.toolbar .summary { margin: 0; }
.toolbar .notice { margin-top: 0; }
.toolbar + .results { margin-top: 0; }
.views {
  display: inline-flex; padding: 3px; gap: 2px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised);
}
.views[hidden] { display: none; }
.views button {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: none; border-radius: 7px;
  padding: 3px 10px; font-size: 0.85rem; color: var(--ink-soft);
}
.views button:hover { color: var(--ink); }
.views button.on { background: var(--brand); color: #fff; }
.views svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.card-title { cursor: pointer; }
.card-title:hover .episode { color: var(--brand); }


.skeleton { height: 112px; padding: 0; background: linear-gradient(90deg, var(--surface-raised), var(--line), var(--surface-raised)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.notice {
  margin-top: 22px; padding: 12px 14px; border-radius: 10px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.notice.error { border: 1px solid var(--danger); color: var(--danger); }
.notice button { border: 1px solid currentColor; background: none; color: inherit; border-radius: 8px; padding: 2px 12px; }

/* pages: the same pill look as the segmented controls */
.pager {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  margin-top: 24px;
}
.pager[hidden] { display: none; }
.pager button {
  min-width: 36px; height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-raised); color: var(--ink-soft); font-size: 0.92rem;
}
.pager button:hover:not(:disabled) { color: var(--brand); border-color: var(--brand); }
.pager button.on { background: var(--brand); border-color: var(--brand); color: #fff; cursor: default; }
.pager button:disabled:not(.on) { opacity: 0.45; cursor: default; }

@media (max-width: 600px) {
  .views button { padding: 3px 8px; }
  .card { grid-template-columns: 1fr; }
  /* the input keeps 16px (smaller makes iOS zoom in); its hint can be smaller */
  .search input::placeholder { font-size: 0.9rem; text-overflow: ellipsis; }
  .search button { padding: 0 16px; }
  /* the home page's big "ابحث بـ" choice, smaller and tucked under the box */
  body:not(.searched) .modes { gap: 14px; margin-top: 10px; font-size: 0.85rem; }
  body:not(.searched) .modes-label { margin-inline-end: -4px; }
  body:not(.searched) .modes button { gap: 6px; }
  body:not(.searched) .modes button::before { width: 14px; height: 14px; border-width: 1.5px; }
  body:not(.searched) .modes button.on::before { box-shadow: inset 0 0 0 2.5px var(--surface-raised); }
}
