/* ============================================================
   Single stylesheet — AI Image & Video Generator mockups
   ============================================================ */

/* --- reset & base --- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  --body-max-ratio: 4 / 3;
  max-width: calc(100vh * (var(--body-max-ratio)));
  margin: 2rem auto;
  padding: 0 2rem;
  font-family: sans-serif;
  line-height: 1.5;
}

/* --- utility --- */

.muted {
  color: #444;
}
.muted-light {
  color: #888;
}
.small {
  font-size: 0.75rem;
}
.hint {
  font-size: 0.7rem;
  color: #999;
}

/* ============================================================
   Header
   ============================================================ */

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.75rem 0;
  margin-bottom: 2rem;
  gap: 0.5rem 1rem;
}

.header-logo {
  font-weight: 700;
  text-decoration: none;
  color: #000;
  font-size: 1rem;
  order: 0;
}

/* nav */
.header nav {
  display: flex;
  gap: 0.25rem;
  order: 1;
  flex: 1;
}

.header nav a {
  text-decoration: none;
  color: #444;
  font-size: 1rem;
  padding: 0.3rem 0.6rem;
}

.header nav a:hover {
  color: #000;
}
.header nav a.active {
  font-weight: 700;
  color: #000;
  border-bottom: 2px solid #000;
}

/* tokens */
.tokens {
  order: 2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 2px solid #000;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
}

.tokens-icon {
  width: 18px;
  height: 18px;
  border: 2px solid #000;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
}

.tokens-count {
  font-weight: 700;
}

.tokens-refill {
  font-size: 0.75rem;
  color: #444;
  border-left: 1px solid #999;
  padding-left: 0.5rem;
}

.tokens-refill time {
  font-weight: 700;
  color: #000;
  font-variant-numeric: tabular-nums;
}

.header-buy {
  order: 3;
  padding: 0.4rem 0.85rem;
  background: #000;
  color: #fff;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

/* auth */
.header-auth {
  order: 4;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-login,
.btn-signup {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: #fff;
  color: #000;
  border: 2px solid #000;
  white-space: nowrap;
}

.btn-signup {
  background: #000;
  color: #fff;
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
  margin-top: 2rem;
  padding: 1rem 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer small {
  font-size: 0.75rem;
  color: #888;
}

.footer nav {
  display: flex;
  gap: 1rem;
}

.footer nav a {
  text-decoration: none;
  color: #888;
  font-size: 0.75rem;
}

.footer nav a:hover {
  color: #000;
}

/* ============================================================
   Shared page elements
   ============================================================ */

h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.intro {
  color: #444;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.intro strong {
  color: #000;
}
.intro a {
  color: #000;
  font-weight: 700;
}

/* --- form fields --- */

.field {
  display: flex;
  flex-direction: column;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.field-head label {
  font-size: 0.85rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  border: 2px solid #000;
  padding: 0.55rem 0.65rem;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

textarea:focus {
  outline: 2px solid #444;
  outline-offset: -2px;
}

/* --- buttons (shared) --- */

.btn-primary {
  display: block;
  width: 100%;
  padding: 1.1rem 3rem;
  background: #000;
  color: #fff;
  border: 2px solid #000;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  text-align: center;
  text-decoration: none;
}

.btn-outline {
  flex: 1;
  background: none;
  border: 2px solid #000;
  padding: 0.45rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: #000;
  text-align: center;
  text-decoration: none;
}

.btn-filled {
  flex: 1;
  background: #000;
  color: #fff;
  border: 2px solid #000;
  padding: 0.45rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

/* ============================================================
   Feed page  (index)
   ============================================================ */

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
  background: #000;
  color: #fff;
}

.banner h2 {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
}
.banner p {
  margin: 0;
  color: #999;
}

.banner-cta {
  padding: 0.75rem 1.5rem;
  background: #fff;
  color: #000;
  font-weight: 600;
  text-decoration: none;
}

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

.feed-thumb {
  aspect-ratio: 7/9;
  border: 2px solid #000;
  cursor: pointer;
  position: relative;
}

/* --- feed video modal --- */

.video-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
}

.video-overlay.active {
  display: flex;
}

.video-player {
  position: relative;
  height: 100vh;
  aspect-ratio: 7/9;
  max-width: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-player .close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  z-index: 10;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.video-player .close:hover {
  color: #ccc;
}

.video-player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none; /* hidden until a real src is set */
}

.video-player .placeholder {
  color: #555;
  font-size: 1.25rem;
  font-weight: 600;
}

/* ============================================================
   Generate page
   ============================================================ */

.gen-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  grid-template-rows: auto 1fr;
  gap: 1.5rem 2rem;
  margin-bottom: 2rem;
}

.gen-form {
  grid-column: 1;
  grid-row: 1;
}
.gen-gallery {
  grid-column: 1;
  grid-row: 2;
}
.gen-result {
  grid-column: 2;
  grid-row: 1 / -1;
}

/* left column: form */
.gen-form {
  display: flex;
  flex-direction: column;
}

.gen-form .field-prompt textarea {
  min-height: 6rem;
  resize: none;
}
.gen-form .field-neg {
  margin-top: 0.75rem;
}
.gen-form .field-neg textarea {
  min-height: 4rem;
  resize: none;
}
.gen-form .btn-primary {
  margin-top: 0.75rem;
}

/* right column: result */
.gen-result {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  min-height: 180px;
}

/* image preview */
.gen-preview {
  width: 100%;
  aspect-ratio: 7/9;
  position: relative;
  overflow: hidden;
  font-size: 0.85rem;
  color: #999;
  background: #f5f5f5;
  /* keep centring for text placeholders */
  display: flex;
  align-items: center;
  justify-content: center;
}

.gen-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 0;
}

.gen-preview.empty {
  background: none;
  aspect-ratio: auto;
  flex: 1;
  flex-direction: column;
  gap: 0.5rem;
}

.gen-preview .empty-hint {
  font-size: 0.75rem;
  color: #999;
  max-width: 200px;
  text-align: center;
  line-height: 1.4;
}

/* result actions */
.gen-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-animate {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: #000;
  color: #fff;
  border: 2px solid #000;
  cursor: pointer;
  text-align: left;
}

.btn-animate .icon {
  font-size: 1.1rem;
}

.btn-animate .label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.btn-animate .label strong {
  font-size: 0.85rem;
}
.btn-animate .label small {
  font-size: 0.7rem;
  color: #aaa;
}

.actions-row {
  display: flex;
  gap: 0.5rem;
}

/* mini-gallery on generate page */
.gen-gallery {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.gen-gallery h2 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}
.gen-gallery .login-prompt {
  flex: 1;
}

.login-prompt {
  border: 2px dashed #000;
  padding: 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.login-prompt h3 {
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
}
.login-prompt p {
  font-size: 0.8rem;
  color: #444;
  margin-bottom: 1rem;
}

.login-prompt .buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.login-prompt .buttons .btn-login,
.login-prompt .buttons .btn-signup {
  padding: 0.6rem 1.75rem;
  font-size: 0.85rem;
  font-weight: 700;
}

/* ============================================================
   Generate loading state
   ============================================================ */

.loading-preview {
  background: none;
  aspect-ratio: auto;
  flex: 1;
  flex-direction: column;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 70%;
  max-width: 260px;
}

/* spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #ddd;
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-step {
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
}

/* progress bar */
.loading-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: #000;
  border-radius: 4px;
  transition: width 0.15s ease-out;
}

.loading-pct {
  font-size: 0.75rem;
  font-weight: 700;
  color: #555;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Image fullscreen lightbox
   ============================================================ */

.gen-preview-img {
  cursor: pointer;
}

.gen-preview-expand {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.gen-preview:hover .gen-preview-expand {
  opacity: 1;
}

.gen-preview-expand:hover {
  background: rgba(0, 0, 0, 0.8);
}

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.92);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox-overlay.open {
  display: flex;
}

.lightbox-overlay img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  /* reset absolute positioning from .gen-preview img */
  position: static;
  width: auto;
  height: auto;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  z-index: 10;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.75rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.lightbox-close:hover {
  color: #ccc;
}

/* ============================================================
   Animate modal
   ============================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #fff;
  border: 2px solid #000;
  padding: 2.25rem;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal .close {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
}

.modal h2 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.modal-columns {
  display: flex;
  gap: 2.5rem;
  align-items: stretch;
}

.modal-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* modal thumbnail */
.modal-thumb {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}

.modal-thumb-img {
  aspect-ratio: 7/9;
  height: 100%;
  max-height: 100%;
  border: 2px solid #000;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #999;
}

/* modal checkbox */
.modal-toggle {
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

/* modal prompts */
.modal-prompts textarea {
  width: 100%;
}
.modal-prompts.disabled textarea {
  opacity: 0.35;
  pointer-events: none;
}

/* modal video preview */
.modal-video {
  border: 2px solid #000;
  aspect-ratio: 7/9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #999;
  background: #f5f5f5;
}

/* extend button in modal */
.modal-right .btn-outline {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* share buttons */
.share-row {
  display: flex;
  gap: 0.5rem;
}

.btn-share {
  flex: 1;
  padding: 0.45rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  background: #f0f0f0;
  color: #444;
  border: 2px solid #ccc;
  white-space: nowrap;
}

/* ============================================================
   Gallery page
   ============================================================ */

.gallery-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.profile .label {
  color: #555;
}
.profile .name {
  font-weight: 700;
}
.profile .edit {
  font-size: 0.75rem;
  color: #444;
  text-decoration: none;
}

/* tabs */
.tabs {
  display: flex;
  margin-bottom: 1.25rem;
}

.tab {
  border: 2px solid #000;
  padding: 0.35rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  margin-right: -2px;
  position: relative;
  background: none;
  color: #555;
}

.tab.active {
  background: #000;
  color: #fff;
  z-index: 1;
}

.tab-count {
  font-size: 0.7rem;
  font-weight: 400;
  background: #ddd;
  color: #000;
  padding: 0.05rem 0.35rem;
  margin-left: 0.3rem;
}

.tab.active .tab-count {
  background: #555;
  color: #fff;
}

/* gallery grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
}

/* card */
.card {
  border: 2px solid #000;
  display: flex;
  flex-direction: column;
}

.card-thumb {
  aspect-ratio: 7/9;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #999;
  position: relative;
}

.card-thumb.video {
  background: #e6e6e6;
}

.card-thumb .play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  color: #000;
  opacity: 0.4;
  pointer-events: none;
}

.card-meta {
  padding: 0.4rem 0.5rem;
  border-top: 1px solid #ddd;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
}

.card-date {
  font-size: 0.68rem;
  color: #666;
}
.card-dur {
  font-size: 0.68rem;
  font-weight: 700;
}

/* publish badges */
.badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.named {
  background: #000;
  color: #fff;
}
.badge.anon {
  background: #555;
  color: #fff;
}
.badge.unpub {
  background: #e0e0e0;
  color: #444;
}

/* card publish row */
.card-publish {
  padding: 0.4rem 0.5rem;
  border-top: 1px dashed #ddd;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
  margin-top: auto;
}

.card-publish + .card-actions {
  margin-top: 0;
}

/* card actions */
.card-actions {
  padding: 0.3rem 0.4rem;
  border-top: 1px solid #eee;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: auto;
}

.card-btn {
  font-size: 0.6rem;
  color: #888;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
  padding: 0.15rem 0.3rem;
  border: none;
  background: none;
}

.card-btn:hover {
  color: #000;
}

/* ============================================================
   Responsive
   ============================================================ */

/* header */
@media (max-width: 860px) {
  .header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    gap: 0.4rem 1rem;
    align-items: center;
  }

  .header-logo {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
  }
  .header-auth {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    margin-left: 0;
  }
  .tokens {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }
  .header nav {
    grid-column: 1 / -1;
    grid-row: 3;
    flex: none;
    margin-top: 0.5rem;
  }
  .header-buy {
    display: none;
  }
}

/* generate page */
@media (max-width: 860px) {
  .gen-layout {
    grid-template-columns: 1fr;
  }
  .gen-form,
  .gen-result,
  .gen-gallery {
    grid-column: 1;
    grid-row: auto;
  }
  .gen-result {
    order: 2;
    max-width: 420px;
  }
  .gen-gallery {
    order: 3;
  }
  .gen-form .field-prompt textarea {
    min-height: 120px;
  }
}

/* modal */
@media (max-width: 600px) {
  .modal-columns {
    flex-direction: column;
  }
}

/* gallery */
@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .gallery-header {
    flex-direction: column;
  }
}

/* footer */
@media (max-width: 640px) {
  .footer {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
  }
}

/* small screens */
@media (max-width: 480px) {
  body {
    margin-top: 0.75rem;
    padding: 0 1rem;
  }
  .header nav {
    gap: 0;
  }
  .header nav a {
    padding: 0.3rem 0.4rem;
    font-size: 0.9rem;
  }
  .tokens {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
  .btn-login,
  .btn-signup {
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
  }
}
