/* =====================================================================
   IT Tutorials Portal - stylesheet
   Single file, no build step. Dark UI with a light-mode fallback.
   ===================================================================== */

:root {
  --bg:        #0f1420;
  --bg-2:      #161d2b;
  --surface:   #1c2536;
  --surface-2: #232e42;
  --border:    #2c384f;
  --text:      #e7ecf3;
  --text-dim:  #9aa7bd;
  --primary:   #3b82f6;
  --primary-ink: #ffffff;
  --accent:    #22d3ee;
  --danger:    #ef4444;
  --warn:      #f59e0b;
  --ok:        #22c55e;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 6px 24px rgba(0, 0, 0, .35);
  --wrap:      1180px;
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f4f6fb;
    --bg-2:      #eef1f8;
    --surface:   #ffffff;
    --surface-2: #f7f9fc;
    --border:    #dde3ee;
    --text:      #1b2333;
    --text-dim:  #5c6880;
    --shadow:    0 6px 20px rgba(20, 30, 60, .10);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--primary);
  color: #fff; padding: 10px 16px; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex; align-items: center; gap: 18px;
  padding-top: 12px; padding-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand__mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 15px;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong { font-size: 16px; }
.brand__text small { color: var(--text-dim); font-size: 12px; }

.search { display: flex; flex: 1; max-width: 520px; margin-left: auto; }
.search input {
  flex: 1; min-width: 0;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  padding: 10px 14px; font-size: 14px;
}
.search input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.search button {
  background: var(--primary); color: var(--primary-ink);
  border: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.search button:hover { filter: brightness(1.08); }

.nav-toggle {
  display: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px; cursor: pointer;
}

.cat-nav { border-top: 1px solid var(--border); background: var(--bg-2); }
.cat-nav__inner { display: flex; gap: 6px; overflow-x: auto; padding-top: 8px; padding-bottom: 8px; }
.cat-nav a {
  white-space: nowrap; color: var(--text-dim);
  padding: 7px 12px; border-radius: 999px; font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 6px;
}
.cat-nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.cat-nav a.is-active { background: var(--primary); color: #fff; }
.cat-nav__count {
  background: color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 999px; padding: 1px 7px; font-size: 11px;
}

/* ---------- Page shell ---------- */
.page { padding-top: 28px; padding-bottom: 60px; }

.flashes { display: grid; gap: 10px; margin-bottom: 20px; }
.flash {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px;
  border: 1px solid var(--border); background: var(--surface);
}
.flash--success { border-color: var(--ok);     background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.flash--error   { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.flash--warn    { border-color: var(--warn);   background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }

.hero { margin-bottom: 12px; }
.hero h1 { font-size: 28px; }
.hero p { color: var(--text-dim); margin: 0; }

.section { margin-top: 40px; }
.section__title {
  font-size: 18px; margin-bottom: 16px;
  display: flex; align-items: baseline; gap: 12px;
}

.empty {
  color: var(--text-dim); background: var(--surface);
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 30px; text-align: center;
}

/* ---------- Breadcrumbs ---------- */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 18px; font-size: 13px; color: var(--text-dim); }
.crumbs li + li::before { content: "/"; margin-right: 8px; color: var(--border); }

/* ---------- Category grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.cat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 6px; color: var(--text);
  border-top: 3px solid var(--cat-color, var(--primary));
  transition: transform .12s ease, border-color .12s ease;
}
.cat-card:hover { transform: translateY(-2px); text-decoration: none; border-color: var(--cat-color, var(--primary)); }
.cat-card__icon { font-size: 24px; }
.cat-card__name { font-weight: 600; }
.cat-card__count { color: var(--text-dim); font-size: 13px; }
.cat-card__desc { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }

/* ---------- Featured ---------- */
.featured { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.featured__main {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  min-height: 320px; display: block; color: #fff;
}
.featured__main img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.featured__fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 46px; color: var(--text-dim); }
.featured__caption {
  position: absolute; inset: auto 0 0 0; padding: 40px 20px 18px;
  background: linear-gradient(to top, rgba(0,0,0,.85), transparent);
  display: flex; flex-direction: column; gap: 4px;
}
.featured__caption strong { font-size: 18px; }
.featured__caption small { color: #d6dbe4; }
.featured__side { display: grid; gap: 12px; align-content: start; }
.featured__side a {
  display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; color: var(--text); padding-right: 10px;
}
.featured__side a:hover { text-decoration: none; border-color: var(--primary); }
.featured__side-thumb { position: relative; width: 96px; height: 60px; background: var(--surface-2); }
.featured__side-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.featured__side-thumb .featured__fallback { position: absolute; inset: 0; font-size: 18px; }
.featured__side > span { font-size: 13.5px; }

/* ---------- Video grid / cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--primary); }
.card__thumb {
  position: relative; display: block; aspect-ratio: 16 / 9;
  background: var(--surface-2); overflow: hidden;
}
.card__thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface-2); }
.card__thumb-fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; color: var(--text-dim); }
.card__duration {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0,0,0,.82); color: #fff; font-size: 12px;
  padding: 2px 6px; border-radius: 4px;
}
.card__badge {
  position: absolute; left: 8px; top: 8px;
  background: var(--accent); color: #04222a; font-weight: 700;
  font-size: 11px; padding: 2px 8px; border-radius: 4px; text-transform: uppercase;
}
.card__body { padding: 13px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card__title { font-size: 15px; margin: 0; }
.card__title a { color: var(--text); }
.card__title a:hover { color: var(--primary); text-decoration: none; }
.card__meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.card__excerpt { color: var(--text-dim); font-size: 13px; margin: 0; flex: 1; }
.card__foot { color: var(--text-dim); font-size: 12px; margin: 0; display: flex; gap: 5px; }

.chip {
  font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border);
}
a.chip:hover { color: var(--text); text-decoration: none; border-color: var(--primary); }
.chip--beginner     { color: #7ee0a5; border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.chip--intermediate { color: #f6c667; border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.chip--advanced     { color: #f39a9a; border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.chip--admin        { color: #fff; background: var(--primary); border-color: var(--primary); }

/* ---------- List head / filters ---------- */
.list-head {
  border-left: 4px solid var(--cat-color, var(--primary));
  padding-left: 14px; margin-bottom: 22px;
}
.list-head h1 { font-size: 24px; }
.list-head p { color: var(--text-dim); margin: 4px 0 0; }
.list-head__count { font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 22px; }
.filters label { font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 4px; }
.filters select, .filters button {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 14px;
}

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 34px; }
.pager__btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 16px; color: var(--text); font-size: 14px;
}
.pager__btn:hover { border-color: var(--primary); text-decoration: none; }
.pager__status { color: var(--text-dim); font-size: 13px; }

/* ---------- Watch page ---------- */
.watch-layout { display: grid; grid-template-columns: 1fr 340px; gap: 30px; align-items: start; }
.player, .player-embed {
  width: 100%; aspect-ratio: 16 / 9; background: #000;
  border-radius: var(--radius); overflow: hidden; display: block;
}
.player-embed iframe { width: 100%; height: 100%; border: 0; }
.player-embed--fallback {
  display: grid; place-items: center; gap: 12px; text-align: center;
  aspect-ratio: 16 / 9; background: var(--surface); color: var(--text-dim);
  border: 1px dashed var(--border);
}
.watch-title { font-size: 22px; margin: 18px 0 10px; }
.watch-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }
.watch-attachment {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px;
}
.watch-desc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; font-size: 15px;
  white-space: normal; overflow-wrap: anywhere;
}
.watch-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.tag { font-size: 12.5px; color: var(--text-dim); background: var(--surface); border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; }
.tag:hover { color: var(--primary); text-decoration: none; }

.watch-side h2 { font-size: 15px; margin-bottom: 12px; }
.side-list { display: grid; gap: 10px; }
.side-item { display: grid; grid-template-columns: 120px 1fr; gap: 10px; color: var(--text); }
.side-item:hover { text-decoration: none; }
.side-item:hover strong { color: var(--primary); }
.side-item__thumb {
  position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); border-radius: 6px;
  overflow: hidden; color: var(--text-dim);
}
.side-item__fallback { position: absolute; inset: 0; display: grid; place-items: center; }
.side-item__thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.side-item__text { display: flex; flex-direction: column; gap: 3px; }
.side-item__text strong { font-size: 13.5px; line-height: 1.3; }
.side-item__text small { color: var(--text-dim); font-size: 12px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-2); margin-top: 40px; }
.site-footer__inner { display: flex; justify-content: space-between; padding-top: 18px; padding-bottom: 18px; color: var(--text-dim); font-size: 13px; }

/* ---------- Buttons (shared) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--primary); color: var(--primary-ink);
  border: 1px solid var(--primary); border-radius: var(--radius-sm);
  padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--danger { background: var(--danger); border-color: var(--danger); }
.btn--sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .watch-layout { grid-template-columns: 1fr; }
  .featured { grid-template-columns: 1fr; }
  .featured__main { min-height: 220px; }
}
@media (max-width: 720px) {
  .site-header__inner { flex-wrap: wrap; }
  .search { order: 3; max-width: none; width: 100%; }
  .nav-toggle { display: block; margin-left: auto; }
  .cat-nav { display: none; }
  .cat-nav.is-open { display: block; }
  .cat-nav__inner { flex-wrap: wrap; }
}
