:root{
  --bg:#07090d;
  --panel:rgba(255,255,255,.06);
  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.65);
  --line:rgba(255,255,255,.12);
  --radius:18px;
  --max:1100px;
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;
  background:radial-gradient(circle at top left,#111827,#05070a 60%);
  color:var(--text);
}

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

.top{padding:50px 0 10px}

.brand{
  color:var(--muted);
  text-decoration:none;
  font-size:12px;
  letter-spacing:.1em;
}

h1{margin:10px 0 6px;font-size:38px}
.sub{margin:0;color:var(--muted)}

.toolbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  margin:20px 0;
}

.search{
  width:min(560px, 100%);
  background:var(--panel);
  border:1px solid var(--line);
  color:white;
  padding:12px 16px;
  border-radius:999px;
  outline:none;
}

.search:focus{border-color:rgba(255,255,255,.22)}
.count{color:var(--muted)}

@media (max-width: 640px){
  .toolbar{
    flex-direction:column;
    align-items:stretch;
  }
  .count{
    width:100%;
    text-align:left;
  }
}

.grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(160px,1fr));
  gap:20px;
}

.card{
  appearance:none;
  -webkit-appearance:none;
  padding:0;
  text-align:left;
  color:inherit;
  font:inherit;

  border:1px solid var(--line);
  border-radius:var(--radius);
  overflow:hidden;
  cursor:pointer;
  background:#0f1115;
  transition:transform .2s ease, border-color .2s ease;
}

.card:hover{
  transform:translateY(-4px);
  border-color:rgba(255,255,255,.18);
}

.poster{aspect-ratio:2/3;background:rgba(255,255,255,.03)}

.poster img{width:100%;height:100%;object-fit:cover;display:block}

.cardInfo{padding:12px}
.titleRow{display:flex;justify-content:space-between;gap:10px;align-items:baseline}
.year{color:var(--muted);font-size:13px}

/* ===== MODAL ===== */

.modal{display:none;position:fixed;inset:0}
.modal.open{display:block}

.modalBackdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,.70);
  backdrop-filter:blur(8px);
}

.modalPanel{
  position:absolute;
  inset:24px;
  background:#0c0e12;
  border-radius:20px;
  overflow:hidden;
  display:block;
  border:1px solid rgba(255,255,255,.10);
}

.modalBody{
  height:100%;
  display:grid;
  grid-template-columns:1fr;
}

@media (min-width: 900px){
  .modalBody{grid-template-columns:420px 1fr;}
}

.posterCol{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:22px;
  background:rgba(255,255,255,.02);
}

.mPoster{
  width:100%;
  max-width:380px;
  max-height:calc(100vh - 140px);
  object-fit:contain;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
}

.infoCol{
  padding:28px 26px;
  overflow:auto;
}

.close{
  position:absolute;
  top:14px;
  right:14px;
  z-index:10;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(255,255,255,.08);
  color:var(--text);
  border-radius:999px;
  padding:10px 12px;
  cursor:pointer;
}

/* ===== MODAL TEXT ===== */

.kicker{
  color:var(--muted);
  font-size:13px;
  letter-spacing:.12em;
  text-transform:uppercase;
  margin-bottom:14px;
}

#mTitle{
  font-size:34px;
  font-weight:600;
  margin:0 0 14px 0;
  letter-spacing:-0.01em;
}

.logline{
  font-size:17px;
  line-height:1.6;
  color:rgba(255,255,255,.85);
  margin:0 0 28px 0;
  max-width:720px;
}

.meta{
  border-top:1px solid var(--line);
  padding-top:22px;
  margin-top:10px;
  max-width:720px;
}

.meta .row{
  display:grid;
  grid-template-columns:140px 1fr;
  gap:20px;
  padding:10px 0;
  border-bottom:1px solid rgba(255,255,255,.06);
}

.meta .row:last-child{border-bottom:none}

.label{
  color:var(--muted);
  font-size:13px;
  letter-spacing:.05em;
  text-transform:uppercase;
}

.value{
  color:rgba(255,255,255,.9);
  font-size:15px;
  line-height:1.5;
}


/* ===== MOBILE: make the whole modal scroll (poster + text together) ===== */
@media (max-width: 899px){

  .modalPanel{
    inset: 12px;
    border: none;
    border-radius: 18px;
    overflow-y: auto;                 /* key: modal panel scrolls */
    -webkit-overflow-scrolling: touch;/* smooth iOS scroll */
  }

  .modalBody{
    height: auto;                     /* key: remove fixed height behavior */
    display: flex;
    flex-direction: column;
    overflow: visible;                /* no nested scroll here */
  }

  .posterCol{
    padding: 12px 12px 0;
    background: transparent;
    overflow: visible;                /* do not clip poster */
  }

  .mPoster{
    width: 100%;
    height: auto;
    max-height: 62svh;                /* big, still fully visible */
    object-fit: contain;              /* never crop */
    border: none;                     /* remove frame */
    border-radius: 12px;
    display: block;
  }

  @supports not (height: 1svh){
    .mPoster{ max-height: 62vh; }
  }

  .infoCol{
    padding: 16px 18px 26px;
    overflow: visible;                /* key: disable inner scrolling */
    max-height: none;                 /* key: remove height clamp */
  }

  .close{
    position: sticky;                 /* stays reachable while you scroll */
    top: 12px;
    float: right;
    margin: 12px 12px 0 auto;
    z-index: 20;
    background: rgba(255,255,255,.10);
    border: none;
    backdrop-filter: blur(6px);
  }
}