/* sinreel — component layer. Consumes Tier 2 semantic tokens only
 * (--color-*, --gradient-*, --shadow-*). See docs/DESIGN.md. */

@layer components {
  /* Logo is a strict vector asset — see templates/partials/_logo.html and docs/LOGO.md */
  .sinreel-logo, .sinreel-mark { display: block; }

  .app { display: flex; height: 100vh; }

  /* ---------- sidebar ---------- */
  .sidebar {
    width: 210px; flex: 0 0 210px;
    border-right: 1px solid var(--color-border-soft);
    background: var(--color-bg-raised);
    display: flex; flex-direction: column;
    padding: 26px 18px 22px;
  }
  .logo { display: inline-flex; align-items: center; color: var(--logo-ink); padding: 0 8px; margin-bottom: 38px; }
  .logo svg.sinreel-logo { height: 23px; width: auto; }
  .logo svg.sinreel-mark { display: none; height: 30px; width: auto; }

  .nav { display: flex; flex-direction: column; gap: 4px; }
  .nav a {
    display: flex; align-items: center; gap: 15px;
    padding: 12px 14px; border-radius: 11px; color: var(--color-text-muted);
    font-size: 15px; transition: all .18s;
  }
  .nav a svg { width: 21px; height: 21px; flex: 0 0 auto; }
  .nav a:hover { background: var(--color-surface); color: var(--color-text); }
  .nav a.active { background: var(--color-surface); color: var(--color-text); }
  .nav a.active svg { color: var(--color-accent); }

  .side-spacer { flex: 1; }
  .side-cta { display: flex; flex-direction: column; gap: 10px; }
  .btn {
    font-family: inherit; font-size: 14px; font-weight: 500; border: none; cursor: pointer;
    border-radius: 999px; padding: 12px; transition: all .2s; width: 100%;
  }
  .btn-primary { background: var(--gradient-accent); color: var(--color-on-accent); box-shadow: var(--shadow-accent); }
  .btn-primary:hover { filter: brightness(1.08); }
  .btn-ghost { background: var(--color-surface); color: var(--color-text); }
  .btn-ghost:hover { background: var(--color-surface-raised); }
  .side-foot { margin-top: 16px; font-size: 11px; color: var(--color-text-faint); letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; padding: 0 6px; }
  .badge18 { border: 1px solid var(--color-accent); color: var(--color-accent); border-radius: 5px; font-size: 10px; font-weight: 600; padding: 2px 5px; }

  /* ---------- stage ---------- */
  .stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; }
  .stage::before {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(80% 80% at 50% 0%, rgb(var(--accent-deep-rgb) / 0.16) 0%, transparent 60%);
    pointer-events: none;
  }

  /* player = video column + vertical action rail */
  .player { display: flex; align-items: center; justify-content: center; gap: 24px; position: relative; z-index: 1; }

  .vcol { width: var(--video-w); display: flex; flex-direction: column; gap: 14px; }

  /* vertical action rail, to the right of the video */
  .rail { display: flex; flex-direction: column; gap: 16px; align-items: center; flex: 0 0 auto; }
  .rail-sep { width: 28px; height: 1px; background: var(--color-border); margin: 2px 0; }

  /* clean video area — nothing inside */
  .video {
    width: 100%; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden;
    border: 1px solid var(--color-border); box-shadow: var(--shadow-xl);
    background:
      repeating-linear-gradient(135deg, rgb(var(--accent-rgb) / 0.06) 0 14px, rgb(var(--accent-rgb) / 0.015) 14px 28px),
      var(--gradient-media);
    transition: opacity .28s ease, transform .28s ease;
  }
  .video video { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--black); }

  /* empty Explore feed */
  .feed-empty { max-width: 420px; }

  /* control bar below video */
  .controls { display: flex; align-items: center; gap: 13px; }
  .pp {
    width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto; cursor: pointer; border: none;
    background: var(--gradient-accent); color: var(--color-on-accent);
    display: flex; align-items: center; justify-content: center; transition: filter .2s;
  }
  .pp:hover { filter: brightness(1.08); }
  .pp svg { width: 17px; height: 17px; }
  .scrub { flex: 1; height: 5px; border-radius: 5px; background: rgb(var(--overlay-rgb) / 0.13); overflow: hidden; cursor: pointer; }
  .scrub i { display: block; height: 100%; width: 32%; background: var(--color-accent); border-radius: 5px; }
  .time { font-size: 12.5px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

  /* caption + socials row below the video */
  .underbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; }
  .caption { flex: 1; min-width: 0; }
  .caption .who { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }
  .caption .who .av { width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto; background: var(--gradient-avatar); border: 1px solid var(--color-border); }
  .caption .who .h { font-size: 15px; font-weight: 500; color: var(--color-text); }
  .caption .who .follow {
    margin-left: 4px; font-size: 12.5px; font-weight: 500; color: var(--color-accent);
    border: 1px solid var(--color-accent-border); border-radius: 999px; padding: 5px 14px; cursor: pointer; transition: all .2s; white-space: nowrap;
  }
  .caption .who .follow:hover { background: var(--color-accent); color: var(--color-on-accent); border-color: transparent; }
  .caption .txt { font-size: 14.5px; color: rgb(var(--fg-rgb) / 0.9); line-height: 1.45; }
  .caption .tags { color: var(--color-accent); }
  .caption .meta { margin-top: 9px; font-size: 12.5px; color: var(--color-text-faint); display: flex; gap: 14px; white-space: nowrap; }

  /* social actions + nav, horizontal row right of caption */
  .socials { display: flex; align-items: center; gap: 16px; flex: 0 0 auto; padding-top: 2px; }
  .act { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; }
  .act .ic {
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--color-surface); border: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: center; color: var(--color-text); transition: all .18s;
  }
  .act:hover .ic { background: var(--color-surface-raised); transform: translateY(-2px); }
  .act.liked .ic { color: var(--color-accent); border-color: var(--color-accent-border-strong); background: var(--color-accent-soft); }
  .act .ic svg { width: 22px; height: 22px; }
  .act .n { font-size: 12px; color: var(--color-text-muted); font-weight: 400; }

  .divider { width: 1px; height: 40px; background: var(--color-border); margin: 0 2px; flex: 0 0 auto; }

  /* next / prev nav — horizontal */
  .feednav { display: flex; flex-direction: column; align-items: center; gap: 12px; flex: 0 0 auto; }
  .navbtn {
    width: 50px; height: 50px; border-radius: 50%;
    border: 1px solid var(--color-border); background: var(--color-surface);
    color: var(--color-text); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .18s;
  }
  .navbtn:hover { background: var(--color-surface-raised); border-color: var(--color-accent-border); color: var(--color-accent); }
  .navbtn svg { width: 23px; height: 23px; }
  .feednav .count { font-size: 12.5px; color: var(--color-text-muted); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
  .feednav .count b { color: var(--color-text); font-weight: 500; }

  /* top-right utility */
  .stage-top { position: absolute; top: 22px; right: 40px; z-index: 5; display: flex; gap: 12px; align-items: center; }
  .icon-btn {
    width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--color-border);
    background: var(--color-surface); color: var(--color-text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all .2s;
  }
  .icon-btn:hover { color: var(--color-text); background: var(--color-surface-raised); }
  .icon-btn svg { width: 17px; height: 17px; }

  @media (max-width: 880px) {
    .sidebar { width: 76px; flex-basis: 76px; padding: 22px 12px; align-items: center; }
    .logo { margin-bottom: 28px; padding: 0; }
    .logo svg.sinreel-logo { display: none; }
    .logo svg.sinreel-mark { display: block; }
    .nav a { justify-content: center; padding: 12px; }
    .nav a span { display: none; }
    .side-cta .btn { font-size: 0; padding: 12px; height: 44px; }
    .side-foot { display: none; }
  }

  /* ---------- coming soon / construction ---------- */
  .cs-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; position: relative; }
  .cs-wrap::before {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(70% 60% at 50% 30%, rgb(var(--accent-deep-rgb) / 0.16) 0%, transparent 60%);
    pointer-events: none;
  }
  .cs-logo { display: inline-flex; align-items: center; color: var(--logo-ink); z-index: 1; }
  .cs-logo svg { height: 72px; width: auto; }
  .cs-badge { margin-top: 22px; z-index: 1; }
  .cs-title { margin-top: 30px; font-size: 22px; font-weight: 400; color: var(--color-text); z-index: 1; }
  .cs-sub { margin-top: 12px; font-size: 15px; color: var(--color-text-muted); max-width: 440px; line-height: 1.55; z-index: 1; }
  .cs-login { position: absolute; bottom: 28px; left: 0; right: 0; font-size: 12.5px; color: var(--color-text-faint); letter-spacing: 0.04em; z-index: 1; }
  .cs-login a { color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); padding-bottom: 1px; transition: all .2s; }
  .cs-login a:hover { color: var(--color-accent); border-color: var(--color-accent-border); }

  /* ---------- auth (login) ---------- */
  .auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px; }
  .auth-card { width: 100%; max-width: 360px; background: var(--color-bg-raised); border: 1px solid var(--color-border-soft); border-radius: 18px; padding: 36px 32px; box-shadow: var(--shadow-card); }
  .auth-logo { display: flex; align-items: center; justify-content: center; color: var(--logo-ink); }
  .auth-logo svg { height: 30px; width: auto; }
  .auth-card h1 { text-align: center; font-weight: 500; font-size: 16px; color: var(--color-text-muted); margin: 14px 0 26px; letter-spacing: 0.02em; }
  .auth-field { margin-bottom: 16px; }
  .auth-field label { display: block; font-size: 12.5px; color: var(--color-text-muted); margin-bottom: 7px; }
  .auth-card input[type="text"], .auth-card input[type="password"] {
    width: 100%; padding: 12px 14px; border-radius: 11px; border: 1px solid var(--color-border);
    background: var(--color-surface); color: var(--color-text); font-family: inherit; font-size: 14.5px;
    outline: none; transition: border-color .2s;
  }
  .auth-card input[type="text"]:focus, .auth-card input[type="password"]:focus { border-color: var(--color-accent-border-strong); }
  .auth-card .btn { margin-top: 6px; }
  .auth-error { background: var(--color-danger-soft); border: 1px solid var(--color-danger-border); color: var(--color-danger-text); font-size: 13px; padding: 10px 12px; border-radius: 10px; margin-bottom: 18px; }
  .auth-back { text-align: center; margin-top: 18px; font-size: 12.5px; }
  .auth-back a { color: var(--color-text-faint); transition: color .2s; }
  .auth-back a:hover { color: var(--color-accent); }

  /* logout button (stage top, staff view) */
  .logout-form { margin: 0; }

  /* ---------- app content pages (upload / studio / detail) ---------- */
  .content { flex: 1; height: 100vh; overflow-y: auto; padding: 40px 48px 64px; }
  .page { max-width: 980px; }
  .page-narrow { max-width: 560px; }
  .page-title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; color: var(--color-text); }
  .page-sub { font-size: 14px; color: var(--color-text-muted); margin: 0 0 26px; }
  .page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }

  a.btn { display: block; text-align: center; text-decoration: none; box-sizing: border-box; }
  .btn-inline, a.btn-inline { display: inline-block; width: auto; padding: 11px 22px; }

  .flashes { margin-bottom: 22px; display: flex; flex-direction: column; gap: 10px; }
  .flash { font-size: 13.5px; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--color-border); }
  .flash-success { background: var(--color-success-soft); border-color: var(--color-success-border); color: var(--color-success-text); }
  .flash-error { background: var(--color-danger-soft); border-color: var(--color-danger-border); color: var(--color-danger-text); }

  .form-card { display: flex; flex-direction: column; gap: 18px; }
  .form-field { display: flex; flex-direction: column; }
  .form-field label { font-size: 12.5px; color: var(--color-text-muted); margin-bottom: 7px; }
  .form-field .req { color: var(--color-accent); }
  .form-card input[type="text"], .form-card input[type="url"], .form-card textarea, .form-card input[type="file"] {
    width: 100%; padding: 12px 14px; border-radius: 11px; border: 1px solid var(--color-border);
    background: var(--color-surface); color: var(--color-text); font-family: inherit; font-size: 14.5px;
    outline: none; transition: border-color .2s;
  }
  .form-card textarea { resize: vertical; }
  .form-card input[type="file"] { padding: 10px 12px; cursor: pointer; }
  .form-card input:focus, .form-card textarea:focus { border-color: var(--color-accent-border-strong); }
  .field-help { font-size: 12px; color: var(--color-text-faint); margin-top: 6px; }
  .field-error { font-size: 12.5px; color: var(--color-danger-text-strong); margin-top: 6px; }
  .form-card .btn { margin-top: 6px; }

  .vid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 22px; }
  .vid-card { display: flex; flex-direction: column; gap: 11px; }
  .vid-thumb {
    position: relative;
    aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; border: 1px solid var(--color-border);
    background: var(--gradient-media);
    display: flex; align-items: center; justify-content: center; transition: border-color .2s;
  }
  .vid-card:hover .vid-thumb { border-color: var(--color-accent-border); }
  .vid-thumb img { width: 100%; height: 100%; object-fit: cover; }
  .vid-thumb-ph { font-size: 28px; color: var(--color-accent); opacity: 0.8; }
  .vid-dur { position: absolute; right: 8px; bottom: 8px; font-size: 11.5px; font-variant-numeric: tabular-nums;
    background: var(--color-scrim); color: var(--color-text); padding: 2px 7px; border-radius: 6px; }
  .vid-title { font-size: 14.5px; font-weight: 500; color: var(--color-text); }
  .vid-sub { font-size: 12.5px; color: var(--color-text-faint); margin-top: 3px; }

  .vid-card-wrap { position: relative; }
  .vid-del { position: absolute; top: 8px; right: 8px; margin: 0; z-index: 2; }
  .vid-del-btn {
    width: 30px; height: 30px; padding: 0; border: none; border-radius: 8px; cursor: pointer;
    background: rgb(var(--scrim-rgb) / 0.72); color: var(--color-text); font-size: 14px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .2s, background .2s, color .2s;
  }
  .vid-card-wrap:hover .vid-del-btn, .vid-del-btn:focus-visible { opacity: 1; }
  .vid-del-btn:hover { background: var(--color-accent); color: var(--color-on-accent); }
  @media (hover: none) { .vid-del-btn { opacity: 1; } }

  /* publish / unpublish toggle (mirrors the delete control, top-left) */
  .vid-pub { position: absolute; top: 8px; left: 8px; margin: 0; z-index: 2; }
  .vid-pub-btn {
    width: 30px; height: 30px; padding: 0; border: none; border-radius: 8px; cursor: pointer;
    background: rgb(var(--scrim-rgb) / 0.72); color: var(--color-text);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .2s, background .2s, color .2s;
  }
  .vid-pub-btn svg { width: 16px; height: 16px; }
  .vid-pub-btn.is-live { color: var(--color-accent); }
  .vid-card-wrap:hover .vid-pub-btn, .vid-pub-btn:focus-visible { opacity: 1; }
  .vid-pub-btn:hover { background: var(--color-accent); color: var(--color-on-accent); }
  @media (hover: none) { .vid-pub-btn { opacity: 1; } }

  /* draft state — clearly not live */
  .vid-card-wrap.is-draft .vid-thumb { opacity: 0.5; }
  .vid-draft-tag {
    position: absolute; left: 8px; bottom: 8px; z-index: 1;
    font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
    background: var(--color-scrim); color: var(--color-text-muted);
    padding: 3px 7px; border-radius: 6px; border: 1px solid var(--color-border);
  }

  .empty { border: 1px dashed var(--color-border); border-radius: 16px; padding: 48px; text-align: center; color: var(--color-text-muted); }
  .empty p { margin: 0 0 18px; }

  .back-link { display: inline-block; font-size: 13px; color: var(--color-text-muted); margin-bottom: 18px; transition: color .2s; }
  .back-link:hover { color: var(--color-accent); }
  .player-card {
    border-radius: 16px; overflow: hidden; border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg); background: var(--black); margin-bottom: 22px;
  }
  .detail-video { display: block; width: 100%; aspect-ratio: 16 / 9; background: var(--black); }
  .detail-desc { font-size: 14.5px; color: rgb(var(--fg-rgb) / 0.85); line-height: 1.5; margin-top: 16px; }
  .detail-tech { margin-top: 14px; font-size: 12.5px; color: var(--color-text-faint); font-variant-numeric: tabular-nums; }
}
