/*
Theme Name: Brahim Saadi Portfolio
Theme URI: https://example.com/brahim-portfolio
Author: Brahim Saadi
Author URI: https://example.com
Description: Editorial single-page portfolio theme for data analysts. Customizer-driven hero, up to eight YouTube playlist sections with a lightbox player, full focus trapping. Full-color photos and thumbnails. No plugins required.
Version: 1.4.3
Requires at least: 5.9
Tested up to: 6.5
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: brahim-portfolio
Tags: portfolio, one-column, custom-colors, custom-logo, custom-menu, editor-style, full-width-template, threaded-comments
*/

/* ============================================================
   1. Tokens — force light mode, ignore OS dark preference
   ============================================================ */
:root {
  color-scheme: light;
  --bp-bg:      #ffffff;
  --bp-card:    #ffffff;
  --bp-tint:    #fafafa;
  --bp-text:    #1a1a1a;
  --bp-muted:   #6a6a6a;
  --bp-line:    #e8e8e8;
  --bp-line-2:  #1a1a1a;
  --bp-accent:  #1a1a1a; /* default to text; Customizer can change */

  --bp-serif: "Cormorant Garamond", "EB Garamond", Georgia, "Times New Roman", serif;
  --bp-sans:  "DM Sans", -apple-system, system-ui, "Helvetica Neue", Arial, sans-serif;

  --bp-maxw: 1280px;
  --bp-pad:  clamp(20px, 4vw, 56px);
  --bp-nav-h: 72px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: light;
    --bp-bg:     #ffffff;
    --bp-card:   #ffffff;
    --bp-tint:   #fafafa;
    --bp-text:   #1a1a1a;
    --bp-muted:  #6a6a6a;
    --bp-line:   #e8e8e8;
    --bp-line-2: #1a1a1a;
  }
  html, body { background: #ffffff !important; color: #1a1a1a !important; }
}

/* ============================================================
   2. Base
   ============================================================ */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bp-bg);
  color: var(--bp-text);
  font-family: var(--bp-sans);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.bp-wrap {
  max-width: var(--bp-maxw);
  margin: 0 auto;
  padding-left: var(--bp-pad);
  padding-right: var(--bp-pad);
}

.bp-eyebrow {
  font-family: var(--bp-sans);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--bp-text);
}

.bp-pill {
  display: inline-block;
  font-family: var(--bp-sans);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 5px 12px;
  border: 1px solid var(--bp-line-2);
  color: var(--bp-text);
  background: transparent;
  border-radius: 0;
}

/* ============================================================
   3. Top navigation
   ============================================================ */
.bp-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--bp-nav-h);
  background: rgba(255,255,255,0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bp-line);
  z-index: 50;
}
.bp-nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bp-logo {
  font-family: var(--bp-serif);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.005em;
  color: var(--bp-text);
}
.bp-logo em { font-style: italic; font-weight: 300; }
.bp-nav-links {
  display: flex;
  gap: 36px;
  align-items: center;
}
.bp-nav-links a {
  font-family: var(--bp-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bp-text);
  position: relative;
  padding-bottom: 4px;
}
.bp-nav-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--bp-text);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .3s ease;
}
.bp-nav-links a:hover::after { transform: scaleX(1); }
@media (max-width: 720px) { .bp-nav-links { display: none; } }

/* ============================================================
   4. Hero
   ============================================================ */
.bp-hero {
  padding-top: calc(var(--bp-nav-h) + clamp(32px, 6vw, 72px));
  padding-bottom: clamp(16px, 2.5vw, 32px);
  display: flex;
  align-items: flex-start;
}
.bp-hero-grid {
  display: grid;
  grid-template-columns: minmax(280px, 440px) 1fr;
  gap: clamp(40px, 7vw, 96px);
  align-items: center;
  width: 100%;
}
@media (max-width: 880px) {
  .bp-hero { padding-top: calc(var(--bp-nav-h) + 36px); }
  .bp-hero-grid { grid-template-columns: 1fr; gap: 40px; }
}

.bp-photo-frame {
  position: relative;
  aspect-ratio: 4/5;
  width: 100%;
  max-width: 440px;
}
.bp-photo-frame::after {
  content: "";
  position: absolute;
  inset: 14px -14px -14px 14px;
  border: 1px solid var(--bp-text);
  z-index: 0;
  pointer-events: none;
}
.bp-photo {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bp-tint);
}
.bp-photo--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bp-line);
  color: var(--bp-muted);
  font-family: var(--bp-serif);
  font-style: italic;
  font-size: 22px;
  text-align: center;
  padding: 24px;
}

.bp-hero-content { max-width: 640px; }
.bp-hero .bp-eyebrow { margin-bottom: 28px; display: inline-block; }
.bp-hero h1 {
  font-family: var(--bp-serif);
  font-weight: 400;
  font-size: clamp(56px, 9vw, 132px);
  line-height: 0.92;
  letter-spacing: -0.022em;
  margin: 0 0 36px;
  color: var(--bp-text);
  text-wrap: balance;
}
.bp-hero h1 .bp-last {
  font-style: italic;
  font-weight: 300;
  display: block;
}
.bp-hero .bp-bio {
  font-family: var(--bp-serif);
  font-weight: 300;
  font-size: clamp(18px, 1.5vw, 22px);
  line-height: 1.5;
  color: var(--bp-text);
  max-width: 52ch;
  margin: 0 0 36px;
  text-wrap: pretty;
}
.bp-skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.bp-skill-tags li {
  font-family: var(--bp-sans);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 6px 14px;
  border: 1px solid var(--bp-line-2);
}

/* ============================================================
   5. Playlists section
   ============================================================ */
.bp-section {
  padding: clamp(28px, 4vw, 48px) 0 clamp(64px, 10vw, 120px);
  border-top: 1px solid var(--bp-line);
}
.bp-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 36px;
}
.bp-section-head h2 {
  font-family: var(--bp-serif);
  font-weight: 400;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}
.bp-section-head h2 em { font-style: italic; font-weight: 300; }
.bp-section-head .bp-section-meta {
  font-family: var(--bp-sans);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bp-muted);
  text-align: right;
}

/* table-like grid: lines on grid's left+top, lines on each card's right+bottom.
   Column count adapts to how many playlists are populated. */
.bp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  border-left: 1px solid var(--bp-line);
  border-top: 1px solid var(--bp-line);
}
.bp-grid[data-count="1"] { grid-template-columns: 1fr; }
.bp-grid[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.bp-grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
.bp-grid[data-count="4"] { grid-template-columns: repeat(4, 1fr); }
.bp-grid[data-count="5"],
.bp-grid[data-count="6"],
.bp-grid[data-count="7"],
.bp-grid[data-count="8"] { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1080px) { .bp-grid, .bp-grid[data-count] { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .bp-grid, .bp-grid[data-count] { grid-template-columns: 1fr; } }

.bp-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bp-card);
  border-right: 1px solid var(--bp-line);
  border-bottom: 1px solid var(--bp-line);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  padding: 0;
  transition: background .25s ease;
  overflow: hidden;
}
.bp-card:hover { background: var(--bp-tint); }
.bp-card::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--bp-text);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .35s cubic-bezier(.2,.7,.2,1);
}
.bp-card:hover::after,
.bp-card:focus-visible::after { transform: scaleX(1); }
.bp-card:focus-visible { outline: none; }

.bp-card-thumb {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--bp-tint);
  border-bottom: 1px solid var(--bp-line);
}
.bp-card-thumb img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .5s ease;
}
.bp-card:hover .bp-card-thumb img { transform: scale(1.04); }

.bp-card-thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--bp-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--bp-muted);
}

.bp-play {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 56px; height: 56px;
  border: 1px solid var(--bp-text);
  background: rgba(255,255,255,0.92);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background .2s ease, transform .25s ease;
}
.bp-card:hover .bp-play { background: #fff; transform: translate(-50%, -50%) scale(1.05); }
.bp-play svg { width: 16px; height: 16px; fill: var(--bp-text); }

.bp-card-body {
  padding: 20px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}
.bp-card-body .bp-pill { align-self: flex-start; }
.bp-card-title {
  font-family: var(--bp-serif);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.18;
  letter-spacing: -0.01em;
  color: var(--bp-text);
  margin: 0;
  text-wrap: balance;
}
.bp-card-desc {
  font-family: var(--bp-sans);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--bp-muted);
  margin: 0;
  flex: 1;
}
.bp-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--bp-sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bp-text);
}
.bp-card-arrow {
  display: inline-flex;
  width: 28px; height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bp-text);
  transition: background .2s ease, color .2s ease;
}
.bp-card-arrow svg { width: 12px; height: 12px; fill: currentColor; }
.bp-card:hover .bp-card-arrow { background: var(--bp-text); color: #fff; }

/* ============================================================
   6. Modal / lightbox
   ============================================================ */
.bp-modal {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vw, 40px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.bp-modal.is-open { opacity: 1; pointer-events: auto; }

.bp-modal-dialog {
  position: relative;
  background: #fff;
  border: 1px solid var(--bp-text);
  width: min(94vw, 1180px);
  height: 88vh;
  display: flex;
  overflow: hidden;
  transform: translateY(12px);
  transition: transform .25s ease;
}
.bp-modal.is-open .bp-modal-dialog { transform: translateY(0); }
@media (max-width: 880px) {
  .bp-modal-dialog { flex-direction: column; height: 92vh; }
}

.bp-modal-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--bp-line);
  overflow: hidden;
}
@media (max-width: 880px) { .bp-modal-main { border-right: 0; border-bottom: 1px solid var(--bp-line); flex: 1 1 auto; } }

.bp-modal-player {
  position: relative;
  flex: 0 1 auto;            /* don't grow; allow shrink only if info needs its min-height */
  width: 100%;
  aspect-ratio: 16/9;
  background: #1a1a1a;
}
.bp-modal-player iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
}
/* Block clicks on YouTube's title bar (top) and “Watch on YouTube” /
   share buttons (bottom-right) so viewers stay on the portfolio.
   Center of the player remains clickable for play / pause / seek. */
.bp-modal-player::before,
.bp-modal-player::after {
  content: "";
  position: absolute;
  z-index: 3;
  background: transparent;
  pointer-events: auto;
}
.bp-modal-player::before {
  top: 0; left: 0; right: 0;
  height: 72px;
}
.bp-modal-player::after {
  bottom: 0; left: 0; right: 0;
  height: 60px;
}
.bp-modal-player--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bp-tint);
  color: var(--bp-muted);
  text-align: center;
  padding: 32px;
  font-family: var(--bp-serif);
  font-style: italic;
  font-size: 20px;
  aspect-ratio: 16/9;
}

.bp-modal-info {
  flex: 1 1 auto;
  min-height: 200px;         /* always show title + ~6 lines of description */
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}
.bp-modal-info-inner {
  padding: 28px 36px 96px;   /* generous bottom padding so last line is always reachable */
}
#bp-modal-download { display: block; margin-top: 12px; }
#bp-modal-download:empty { display: none; }
.bp-modal-info .bp-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}
.bp-modal-info .bp-counter {
  font-family: var(--bp-sans);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bp-muted);
}
.bp-modal-info h3 {
  font-family: var(--bp-serif);
  font-weight: 400;
  font-size: clamp(26px, 3.2vw, 38px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  color: var(--bp-text);
  text-wrap: balance;
}
.bp-modal-info p {
  font-family: var(--bp-sans);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--bp-muted);
  margin: 0;
  max-width: 64ch;
  white-space: pre-wrap;
}

.bp-download {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding: 10px 18px;
  border: 1px solid var(--bp-text);
  font-family: var(--bp-sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bp-text);
  background: #fff;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.bp-download:hover { background: var(--bp-text); color: #fff; }
.bp-download svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.4; }
.bp-download .bp-download-name { text-transform: none; letter-spacing: 0.02em; opacity: 0.75; font-size: 11.5px; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bp-modal-aside {
  flex: 0 0 320px;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
@media (max-width: 880px) { .bp-modal-aside { flex: 0 0 auto; max-height: 40vh; } }
.bp-aside-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--bp-line);
  font-family: var(--bp-sans);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bp-muted);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.bp-aside-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.bp-aside-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--bp-line);
  cursor: pointer;
  background: transparent;
  width: 100%;
  text-align: left;
  border-left: 0; border-right: 0; border-top: 0;
  font: inherit;
  color: inherit;
  transition: background .15s ease;
}
.bp-aside-item:hover { background: var(--bp-tint); }
.bp-aside-item.is-active { background: var(--bp-tint); }
.bp-aside-item.is-active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--bp-text);
}
.bp-aside-item { position: relative; }
.bp-aside-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bp-tint);
  overflow: hidden;
  border: 1px solid var(--bp-line);
}
.bp-aside-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.bp-aside-num {
  position: absolute;
  top: 4px; left: 4px;
  background: #fff;
  border: 1px solid var(--bp-text);
  font-family: var(--bp-sans);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  color: var(--bp-text);
}
.bp-aside-title {
  font-family: var(--bp-serif);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.25;
  color: var(--bp-text);
  letter-spacing: -0.005em;
  margin: 0;
  text-wrap: balance;
}
.bp-aside-empty {
  padding: 32px 24px;
  font-family: var(--bp-serif);
  font-style: italic;
  font-size: 16px;
  color: var(--bp-muted);
  text-align: center;
}

.bp-modal-close {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--bp-text);
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  padding: 0;
}
.bp-modal-close svg { width: 14px; height: 14px; stroke: var(--bp-text); stroke-width: 1.5; }
.bp-modal-close:hover { background: var(--bp-text); }
.bp-modal-close:hover svg { stroke: #fff; }

/* ============================================================
   7. Footer
   ============================================================ */
.bp-foot {
  border-top: 1px solid var(--bp-line);
  padding: 28px 0;
}
.bp-foot-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--bp-sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bp-muted);
}

/* ============================================================
   8. Body scroll lock when modal open
   ============================================================ */
body.bp-no-scroll { overflow: hidden; }

/* ============================================================
   9. Accessibility focus rings
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--bp-text);
  outline-offset: 2px;
}
.bp-card:focus-visible,
.bp-aside-item:focus-visible {
  outline: 2px solid var(--bp-text);
  outline-offset: -2px;
}

/* small print/utility */
.bp-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
