/* MovieChain App CSS
   Sections:
   1) Base
   2) Header
   3) App / Nodes
   4) Autocomplete
   5) Validation
   6) Modal
   7) Footer
*/

/* =========================
   1) Base
   ========================= */
:root {
  --bg:     #0b0d12;
  --panel:  #141a27;
  --line:   rgba(255,255,255,.22);
  --text:   #e9edf5;
  --muted:  #a9b2c3;
  --radius: 16px;

  --font: 'Roboto', system-ui, -apple-system, Segoe UI, Helvetica, Arial, sans-serif;
  --font-body: var(--font);

  --green: rgb(35,134,54);
  --red:   rgb(192,0,0);

  --posterW: 80px;
  --labelW:  300px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body.keyboard-open {
  padding-bottom: var(--kb-space, 0px);
}

input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: #FFF;
  font-size: 16px;
  font-weight: 400;
  text-align: center;
  padding: 4px 2px;
}
input::placeholder { color: rgba(169,178,195,.65); }
.labelBar input::placeholder { color: #fff; }
.labelBar input:focus::placeholder { color: transparent; }

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 14px 20px;
}
.column {
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* =========================
   2) Header
   ========================= */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0;
}

.topbar {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #15161b;
}
.topbar__inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.topbar__logo {
  height: 20px;
  width: auto;
  display: block;
}

.topbar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.iconBtn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 10px;
}
.iconBtn:focus-visible {
  outline: 2px solid rgba(46,204,113,.55);
  outline-offset: 2px;
}
.iconBtn--help {
  border: 1px solid #CCCCCC;
  border-radius: 999px;
  width: 25px;
  height: 25px;
}
.iconBtn--share {
  width: 32px;
  height: 32px;
}

/* Puzzle date line */
.puzzleDate {
  text-align: center;
  font-size: 14px;
  color: rgba(233,237,245,.50);
  font-weight: 400;
  padding: 8px 0 28px;
}

.difficultyPill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 7px;
  position: relative;
  top: -1px;
  text-decoration: none;
  cursor: pointer;
}
.difficultyPill--easy {
  background: rgba(111,207,151,.12);
  color: #6fcf97;
  border: 1px solid rgba(111,207,151,.35);
}
.difficultyPill--hard {
  background: rgba(226,133,74,.12);
  color: #e2854a;
  border: 1px solid rgba(226,133,74,.35);
}

/* =========================
   3) App / Nodes
   ========================= */

/* Row 1: Start + End side by side */
.row1 {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  width: 100%;
  padding: 14px 0;
  margin-bottom: 15px;
}

.movieCol {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  flex: 1;
  min-width: 0;
}

.movieCol__label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.movieCol__title {
  font-size: 14px;
  font-weight: 400;
  color: rgba(233,237,245,.75);
  text-align: center;
  line-height: 1.3;
  padding: 0 4px;
  text-transform: uppercase;
}


/* Chain icon between the two columns, aligned with the poster level */
.row1__chain {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  padding-top: 35px; /* (poster 110px / 2) - (icon layout 40px / 2) = 35 */
  display: flex;
  flex-direction: column;
  align-items: center;
}
.row1__chain img {
  width: 20px;
  height: 40px;
  transform: rotate(90deg);
  opacity: .85;
}
/* Vertical line from just below the chain icon to the box — height driven by JS */
.row1__chain::after {
  content: "";
  position: absolute;
  top: 67px; /* padding-top(35) + icon layout height(40) - 8px overlap */
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: var(--chain-line-h, 90px);
  background: var(--line);
  pointer-events: none;
}

/* Row 2: Connecting movie picker */
.row2 {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-top: 10px; /* clears the ::after line from row1__chain */
}

/* Bordered box containing the prompt + picker — matches search field width */
.row2__box {
  width: var(--labelW);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 12px 20px;
  gap: 10px;
  background: rgba(255,255,255,.02);
}

.row2__prompt {
  margin: 6px 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.node {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Poster block */
.moviePoster {
  width: var(--posterW);
  aspect-ratio: 1/1;
  border: 1px solid var(--line);
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255,255,255,.04);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.moviePoster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#movie-poster-middle img {
  width: 100%;
  height: 100%;
}

#movie-poster-middle.moviePoster--placeholder img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  opacity: 0.2;
}

/* Poster size variants */
.moviePoster--sm { width: 110px; }
.moviePoster--lg { width: 130px; }

/* Inside the row2 box, darken the poster circle */
.row2__box .moviePoster--lg { background: var(--bg); }

button.moviePoster {
  cursor: pointer;
  border: 1px solid var(--line);
  color: inherit;
}
button.moviePoster:focus-visible {
  outline: 2px solid rgba(233,237,245,.45);
  outline-offset: 3px;
}

/* Label bar */
.field {
  width: var(--labelW);
  max-width: 100%;
  margin: 0;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius: 6px;
  padding: 10px 12px;
  position: relative;
}
.labelBar {
  height: 40px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.labelBar input {
  height: 24px;
  line-height: 24px;
  padding: 0;
}
.field__clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  display: none;
}
.field__clear:hover { color: var(--text); }
.field--has-value .field__clear { display: block; }
.labelBar--locked {
  background-image: url("../img/lock.png");
  background-repeat: no-repeat;
  background-position: 10px;
}
.labelText {
  font-size: 14px;
  font-weight: 400;
  line-height: 24px;
  text-align: center;
}


/* =========================
   4) Autocomplete
   ========================= */
.results {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(100% + 8px);
  background: rgba(20,26,39,.98);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: min(320px, 55vh);
  overflow-x: hidden;
  overflow-y: auto;
  display: none;
  z-index: 20;
}
.results.open { display: block; }

.results button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.results button:hover { background: rgba(255,255,255,.06); }

.meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.rLeft {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.rText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thumb {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.14);
  flex: 0 0 auto;
}
.thumb--empty {
  display: inline-block;
  background: rgba(255,255,255,.06);
}

/* =========================
   5) Validation
   ========================= */
.status {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,.04);
  font-weight: 400;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 1rem;
  margin: 10px 0 18px;
  font-family: var(--font-body);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
}
.status--footer {
  width: 100%;
  max-width: 760px;
}
.status:empty { display: none; }

.status[data-kind="working"] {
  color: rgba(233,237,245,.85);
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.14);
}
.status[data-kind="success"] {
  color: var(--text);
  background: rgba(46,204,113,.50);
  border-color: rgba(46,204,113,.50);
}
.status[data-kind="error"] {
  color: var(--text);
  background: rgba(231,76,60,.12);
  border-color: rgba(231,76,60,.35);
}

/* =========================
   6) Modal
   ========================= */
.mcModal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.mcModal[hidden] { display: none; }

.mcModal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}

.mcModal__panel {
  position: relative;
  width: min(420px, calc(100% - 32px));
  aspect-ratio: 1 / 1;
  max-height: min(520px, calc(100vh - 64px));
  background: #ffffff;
  border: 5px solid #666666;
  border-radius: 7px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.mcModal__title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
}
.mcModal__body { overflow: auto; }

.mcModal__panel h2 {
  font-weight: 400;
  font-size: 22px;
  margin: 10px 0 0;
  color: #141a27;
}
.mcModal__body p {
  margin-bottom: 5px;
  font-size: 16px;
  line-height: 1.2;
  color: #15161b;
}
.mcModal__body p:last-child { margin-bottom: 0; }

.mcModal__actions {
  display: flex;
  justify-content: center;
  margin-top: 15px;
}
.mcModal__closeBtn {
  appearance: none;
  border: none;
  background: var(--green);
  color: #ffffff;
  border-radius: 6px;
  padding: 14px 60px;
  font-weight: 500;
  cursor: pointer;
}
.mcModal__closeBtn:hover { filter: brightness(1.05); }

/* Success modal */
.mcModal__panel--success {
  display: flex;
  flex-direction: column;
  border-color: var(--green);
}
.mcModal__panel--success .mcModal__title,
.mcModal__panel--error .mcModal__title {
  color: var(--red);
  text-align: center;
  width: 100%;
}
.mcModal__panel--success .mcModal__body,
.mcModal__panel--error .mcModal__body {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  gap: 14px;
  padding-top: 0;
}
.mcModal__panel--success .mcModal__actions {
  width: 100%;
  display: flex;
  justify-content: center;
}
.mcModal__success,
.mcModal__errorMsg,
.mcModal__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
}
.mcModal__successImg,
.mcModal__oopsImg {
  width: 160px;
  height: auto;
  display: block;
}

/* Error modal */
.mcModal__panel--error {
  display: flex;
  flex-direction: column;
  border-color: var(--red);
}
.mcModal__errorMsg {
  position: relative;
  font-weight: 500;
  padding-left: 20px;
  line-height: 1.45;
}
.mcModal__errorMsg::before {
  color: var(--red);
  content: "✕";
  position: absolute;
  left: 0;
  top: 0.35em;
  font-size: 18px;
  font-weight: 700;
}

/* Modal close button */
.mcModal__x {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  font-weight: 500;
  background: #ffffff;
  color: #444;
  border: 5px solid #666666;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
}
.mcModal__x:hover { color: #000; }
.mcModal__panel--success .mcModal__x { border-color: var(--green); }
.mcModal__panel--error   .mcModal__x { border-color: var(--red); }

/* =========================
   7) Footer
   ========================= */
.footer {
  padding: 0 14px;
}
.footer__inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
.footer__inner--stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.footer__row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.footer__btn {
  background: var(--green);
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 400;
  letter-spacing: .08em;
  margin: 10px 0 18px;
  padding: 10px 20px;
  text-transform: uppercase;
  display: inline-block;
  min-width: 300px;
}
.footer__btn.enabled {
  cursor: pointer;
  color: rgba(255,255,255,1);
}
.footer__btn--primary:disabled {
  color: rgba(204,204,204,.8);
  cursor: not-allowed;
}

/* Stumped / reveal link */
.footer__row--hint {
  justify-content: center;
  padding-bottom: 8px;
}
.stumpedLink {
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
}
.stumpedLink:hover { color: var(--text); }

/* =========================
   8) Reveal Modal
   ========================= */
.mcModal__panel--reveal .mcModal__title {
  color: #141a27;
  text-align: center;
  width: 100%;
}
.mcModal__panel--reveal .mcModal__body {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.mcModal__panel--reveal .mcModal__actions {
  width: 100%;
  display: flex;
  justify-content: center;
}

.mcModal__reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 4px 0;
}
.mcModal__revealLoading {
  color: #888;
  font-size: 14px;
  text-align: center;
}
.mcModal__revealPoster {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.18);
  flex-shrink: 0;
  background: rgba(0,0,0,.06);
}
.mcModal__revealPoster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mcModal__revealTitle {
  font-size: 15px;
  font-weight: 700;
  color: #141a27;
  text-align: center;
  line-height: 1.3;
}
.mcModal__revealActors {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.revealLink {
  background: rgba(0,0,0,.05);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.revealLink__movies {
  font-size: 13px;
  font-weight: 600;
  color: #222;
}
.revealLink__via {
  font-size: 12px;
  color: #555;
  font-style: italic;
}
