/* ===== MODERN VIEW - Responsive CSS ===== */

/* Full-height layout with sticky footer */
html {
  height: 100%;
  background-color: #171616; /* match body so iOS overscroll area doesn't show system gray */
  /* Note: overflow-x: hidden on html/body is ignored by iOS Safari for touch scrolling */
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  -webkit-text-size-adjust: 100%; /* prevent iOS from auto-resizing text */
  display: flex;
  flex-direction: column;
  background-color: #171616;
  font-family: 'Source Sans Pro', 'lucida grande', verdana, helvetica, arial, sans-serif;
  font-weight: 300;
  color: #ccc;
}

a {
  color: #449cc5;
}

a:hover {
  color: #449cc5;
  text-decoration: underline;
}

/* CSS Custom Properties */
:root {
  --twl-blue: #449cc5;
  --twl-blue-hover: #357aa0;
  --twl-nav-bg: #2a2a2a;
  --twl-card-bg: #222;
  --twl-input-bg: #1a1a1a;
  --twl-border: #444;
  --twl-text: #ddd;
  --twl-muted: #888;
  --twl-danger: #d32f2f;
}

/* Alpine.js cloak */
[x-cloak] { display: none !important; }

/* Full-width outer wrapper — nav and footer extend edge to edge */
#all_content {
  width: 100%;
  max-width: 100%;
  min-width: 0; /* override twl-min.css min-width: 1028px */
  overflow-x: clip; /* clip (not hidden) prevents iOS from creating a scroll container */
  position: relative; /* needed for overflow-x: clip to work on iOS */
  touch-action: pan-y; /* prevent horizontal swipe/panning on iOS */
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
}

/* Content area centered with max-width */
#main_content {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: calc(50px + env(safe-area-inset-top, 0px)) 16px 0;
  box-sizing: border-box;
  float: none;
  flex: 1 0 auto;
}

/* ===== Responsive Nav ===== */
.twl-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) 16px 0;
  background: #2a2a2a;
  min-height: 50px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  box-sizing: border-box;
}

.twl-nav__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.twl-nav__icon {
  display: block;
  width: 36px;
  height: 36px;
  background: url('/img/AppIcon-60@2x.png') no-repeat center;
  background-size: contain;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.twl-nav__title {
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
  margin-left: 10px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.twl-nav__title:hover {
  color: #ccc;
}

.twl-nav__links {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.twl-nav__links a {
  color: #ccc;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}

.twl-nav__links a:hover {
  color: #fff;
}

.twl-nav__username {
  color: #888;
  font-size: 13px;
}

.twl-nav__hamburger {
  display: none;
  background: none;
  border: none;
  color: #ccc;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
}

.twl-nav__backdrop {
  display: none;
}

.twl-view-toggle {
  background: #449cc5 !important;
  color: #fff !important;
  padding: 4px 10px !important;
  border-radius: 4px;
  font-size: 13px;
  text-decoration: none !important;
}

.twl-view-toggle:hover {
  background: #357aa0 !important;
}

/* ===== Mark Cards - Responsive ===== */
.mark-item {
  display: flex;
  flex-direction: row;
  min-height: 120px;
  border-bottom: 1px solid #333;
  padding: 10px 0;
  align-items: flex-start;
  box-sizing: border-box;
  width: 100%;
}

.mark-thumbnail-horizontal {
  width: 220px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.mark-thumbnail-horizontal img {
  width: 100%;
  height: auto;
  display: block;
}

.mark-details {
  flex: 1;
  padding: 0 12px;
  overflow: hidden;
  min-width: 0;
  box-sizing: border-box;
}

.mark-title {
  font-size: 16px;
  font-weight: bold;
  margin: 0 0 6px 0;
}

.mark-title a {
  color: #449cc5;
  text-decoration: none;
}

.mark-title a:hover {
  text-decoration: underline;
}

.mark-meta {
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
}

.mark-description-text {
  font-size: 13px;
  color: #aaa;
  white-space: normal;
  overflow: hidden;
  max-height: 60px;
  text-overflow: ellipsis;
}

.mark-buttons {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  padding-top: 2px;
}

/* Status icon column — hidden on desktop (mark-buttons used instead), shown on mobile */
.mark-status-icons {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  padding: 0 6px;
}

.btn-mark-small {
  display: block;
  width: 120px;
  box-sizing: border-box;
  text-align: center;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  border: 1px solid #555;
  background: #333;
  color: #ccc;
  white-space: nowrap;
}

.btn-mark-small:hover {
  background: #444;
  color: #fff;
}

.btn-mark-small.active {
  background: #449cc5;
  border-color: #337ab7;
  color: #fff;
}

/* ===== Filter Tabs (inside sticky footer) ===== */
.twl-filter-tabs {
  display: flex;
  gap: 0;
  margin: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.twl-filter-tab {
  flex: 1;
  padding: 14px 6px;
  border-radius: 0;
  border: none;
  border-right: 1px solid #333;
  color: #ccc;
  cursor: pointer;
  background: transparent;
  white-space: nowrap;
  font-size: 13px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.twl-filter-tab:last-child { border-right: none; }
.twl-filter-tab.active { color: #449cc5; }

/* ===== Pagination ===== */
.twl-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 16px 0;
  flex-wrap: wrap;
}

.twl-page-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid #449cc5;
  border-radius: 4px;
  color: #449cc5;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
}

.twl-page-btn.active {
  background: #449cc5;
  color: #fff;
}

.twl-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Swipe Feedback ===== */
.mark-swipe-wrapper {
  position: relative;
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: 0 120px;
}

/* Background action panels revealed as card slides */
.swipe-bg {
  position: absolute;
  top: 0; bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  font-size: 26px;
  color: #fff;
}

.swipe-bg--left {
  /* Viewed action — muted teal until threshold */
  background: #1a4d66;
  justify-content: flex-start;
  padding-left: 16px;
}

.swipe-bg--right {
  /* Favorite action — muted gold until threshold */
  background: #5c3908;
  justify-content: flex-end;
  padding-right: 16px;
}

/* Bright pop when swipe threshold is crossed */
.swipe-bg--triggered.swipe-bg--left  { background: #2a8fbf; }
.swipe-bg--triggered.swipe-bg--right { background: #c8860a; }

.twl-mark-card {
  position: relative;
  z-index: 1;
  background: #171616;
}

.twl-mark-card--snapping {
  transition: transform 0.25s ease-out;
}


/* ===== Loading / Empty States ===== */
.twl-loading {
  text-align: center;
  padding: 40px;
  color: #888;
}

.twl-empty {
  text-align: center;
  padding: 60px 20px;
  color: #888;
}

.twl-error {
  text-align: center;
  padding: 20px;
  color: #e55;
}

/* ===== Content Pages (settings, tools, etc.) ===== */
.twl-content-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Form Pages ===== */
.twl-form-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Modern Hero (home page) ===== */
.twl-hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  padding: 60px 20px;
  text-align: center;
  border-radius: 8px;
  margin: 20px 0;
  box-sizing: border-box;
  width: 100%;
}

.twl-hero h1 {
  font-size: 36px;
  color: #fff;
  margin: 0 0 12px 0;
}

.twl-hero p {
  font-size: 18px;
  color: #aac;
  margin: 0 0 30px 0;
}

.twl-hero-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.twl-btn-primary {
  background: #449cc5;
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s ease;
}

.twl-btn-primary:hover {
  background: #357aa0;
}

.twl-btn-secondary {
  background: transparent;
  color: #449cc5;
  padding: 12px 28px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 16px;
  border: 2px solid #449cc5;
}

.twl-btn-secondary:hover {
  background: rgba(68,156,197,0.1);
}

.twl-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 30px 0;
}

.twl-feature-block {
  background: #222;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}

.twl-feature-block h3 {
  color: #449cc5;
  margin: 0 0 8px 0;
  font-size: 18px;
}

.twl-feature-block p {
  color: #aaa;
  font-size: 14px;
  margin: 0;
}

.twl-feature-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.twl-appstore {
  text-align: center;
  margin: 30px 0;
}

/* ===== Auth Pages (login/register/forgot) ===== */
#main_content .view {
  float: none !important;
  width: 100% !important; /* override twl-min.css div.view { width: 875px } */
  border: none !important;
  background: none !important;
  padding: 40px 20px;
  max-width: 520px;
  margin: 0 auto;
  box-sizing: border-box;
}

#main_content .actions {
  display: none;
}

#main_content .viewbox {
  max-width: 460px;
  background: #2a2a2a;
  border-radius: 8px;
  padding: 24px 28px;
}

#main_content .header-text h2 {
  color: #ccc;
  margin: 0 0 20px 0;
  font-size: 22px;
}

#main_content .input label {
  display: block;
  color: #aaa;
  font-size: 13px;
  margin-bottom: 4px;
}

#main_content .input input[type="email"],
#main_content .input input[type="password"],
#main_content .input input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  background: #1e1e1e;
  border: 1px solid #555;
  border-radius: 4px;
  color: #ddd;
  padding: 8px 10px;
  font-size: 14px;
  margin-bottom: 14px;
}

#main_content .input.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: #aaa;
  font-size: 13px;
}

#main_content .submit input[type="submit"] {
  background: #449cc5;
  border: none;
  color: #fff;
  padding: 9px 24px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}

#main_content .submit input[type="submit"]:hover {
  background: #357aa0;
}

/* ===== Footer ===== */
#footer {
  clear: both;
  padding: 20px 16px;
  margin: 0;
  border-top: 1px solid #333;
  background: #1a1a1a;
  width: 100%;
  min-width: 0; /* override twl-min.css min-width: 1028px */
  box-sizing: border-box;
  text-align: center;
  font-size: 13px;
  color: #888;
}

#footer a {
  color: #449cc5;
  text-decoration: none;
}

#footer a:hover {
  text-decoration: underline;
}

/* ===== Alert Messages ===== */
.alert {
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 6px;
  background: var(--twl-card-bg);
  border: 1px solid var(--twl-border);
  color: var(--twl-text);
  font-size: 14px;
}

.alert-error {
  background: rgba(211, 47, 47, 0.15);
  border-color: #d32f2f;
  color: #ff6b6b;
}

.alert-success {
  background: rgba(76, 175, 80, 0.15);
  border-color: #4caf50;
  color: #81c784;
}

.alert-info {
  background: rgba(33, 150, 243, 0.15);
  border-color: #2196f3;
  color: #64b5f6;
}

/* ===== Form Inputs ===== */
.twl-input,
input.twl-input,
textarea.twl-input,
select.twl-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--twl-border);
  border-radius: 4px;
  background: var(--twl-input-bg);
  color: var(--twl-text);
  font-size: 15px;
  font-family: inherit;
  box-sizing: border-box;
}

.twl-input:focus,
input.twl-input:focus,
textarea.twl-input:focus,
select.twl-input:focus {
  outline: 2px solid var(--twl-blue);
  outline-offset: 2px;
  border-color: var(--twl-blue);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--twl-blue);
  outline-offset: 2px;
}

textarea.twl-input {
  resize: vertical;
  min-height: 120px;
}

/* ===== Buttons ===== */
.twl-btn-danger {
  background: var(--twl-danger);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.twl-btn-danger:hover {
  background: #c62828;
}

.twl-btn-primary.btn-sm,
.twl-btn-secondary.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
}

/* ===== Content Page Padding ===== */
.twl-content-page {
  padding-top: 32px;
}

.twl-form-page {
  padding-top: 32px;
}

/* ===== Dark Theme Text ===== */
#main_content h1,
#main_content h2,
#main_content h3 {
  color: var(--twl-text);
}

/* ===== Description Text Clamping ===== */
.mark-description-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Dividers ===== */
.twl-divider,
hr {
  border: none;
  border-top: 1px solid var(--twl-border);
  margin: 20px 0;
  height: 0;
}

/* ===== Section Wrapper ===== */
.twl-section {
  margin-bottom: 24px;
}

.twl-section h2,
.twl-section h3 {
  margin-top: 0;
  margin-bottom: 16px;
}

/* ===== Auth Page Centering ===== */
.auth-page #main_content {
  min-height: calc(100vh - 50px - 60px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mark-duration-badge {
  display: none; /* shown only on mobile — desktop uses meta subtitle line */
  position: absolute;
  bottom: 3px;
  right: 3px;
  font-size: 10px;
  color: #fff;
  background: rgba(0,0,0,0.75);
  padding: 1px 4px;
  border-radius: 2px;
  pointer-events: none;
}

/* ===== Mobile: ≤768px ===== */
@media (max-width: 768px) {
  #main_content {
    padding: calc(50px + env(safe-area-inset-top, 0px)) 8px 0;
  }

  .twl-nav__hamburger {
    display: block;
  }

  .twl-nav__backdrop.open {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .twl-nav__links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2a2a2a;
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 0;
    gap: 0;
    z-index: 100;
    border-top: 1px solid #444;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  }

  .twl-nav__links a {
    font-size: 18px;
    padding: 14px 20px;
    width: 100%;
    box-sizing: border-box;
  }

  .twl-nav__username {
    font-size: 16px;
    padding: 14px 20px;
    width: 100%;
    box-sizing: border-box;
    display: block;
  }

  .twl-nav__links.open {
    display: flex;
  }

  /* Mobile compact list rows */
  .mark-item {
    flex-direction: row;
    min-height: 0;
    max-height: 80px;
    height: 80px;
    align-items: center;
    padding: 6px 0;
    cursor: pointer;
    overflow: hidden;
  }

  .mark-thumbnail-horizontal {
    width: 120px;
    min-width: 120px;
    height: 68px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 3px;
  }

  .mark-thumbnail-horizontal img {
    width: 120px;
    height: 68px;
    object-fit: cover;
  }

  .mark-details {
    flex: 1;
    padding: 0 8px;
    overflow: hidden;
    min-width: 0;
  }

  .mark-title {
    font-size: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    margin-bottom: 0;
  }

  .mark-description-text { display: none; }

  /* Hide entire meta line on mobile — duration badge on thumbnail covers it */
  .mark-meta { display: none; }

  .mark-buttons { display: none; }

  /* Show ★/✓ state icons stacked on the right of each row */
  .mark-status-icons {
    display: flex;
  }

  /* Show duration badge over thumbnail on mobile */
  .mark-duration-badge { display: block; }

  .twl-hero h1 {
    font-size: 26px;
  }

  .twl-features {
    grid-template-columns: 1fr;
  }
}

.mark-status-icon {
  font-size: 24px;
  color: #555;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 12px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mark-status-icon.active { color: #449cc5; }

/* Duration badge — overlaid on thumbnail */
.mark-thumb-wrap {
  position: relative;
  flex-shrink: 0;
}

/* ===== Detail Page ===== */
.twl-detail-page { max-width: 700px; margin: 0 auto; padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
.twl-marks-app { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
.twl-detail-embed { position: relative; width: 100%; padding-top: 56.25%; background: #000; }
.twl-detail-embed iframe { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; border: 0; }
.twl-detail-info { padding: 12px 16px; }
.twl-detail-title { font-size: 18px; margin: 0 0 6px; line-height: 1.3; color: var(--twl-text); }
.twl-detail-channel { font-size: 13px; color: var(--twl-muted); margin-bottom: 4px; }
.twl-detail-stats { font-size: 12px; color: var(--twl-muted); display: flex; gap: 12px; }
.twl-detail-description { padding: 0 16px 16px; font-size: 14px; color: #aaa; line-height: 1.6;
                           overflow-wrap: break-word; }
.twl-detail-description a { color: var(--twl-blue); }
/* .twl-detail-actions/.twl-detail-btn replaced by .twl-sticky-footer/.twl-sticky-footer__btn */

/* ===== Shared Sticky Footer ===== */
.twl-sticky-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #1a1a1a;
  border-top: 1px solid #333;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.twl-sticky-footer::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  height: 1px;
  background: #333;
}

.twl-sticky-footer__btn {
  flex: 1;
  padding: 14px 6px;
  text-align: center;
  font-size: 13px;
  color: #ccc;
  background: transparent;
  border: none;
  border-right: 1px solid #333;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.twl-sticky-footer__btn:last-child { border-right: none; }
.twl-sticky-footer__btn.active { color: #449cc5; }

/* ===== Phone: ≤480px ===== */
@media (max-width: 480px) {
  .twl-nav {
    padding: 0 10px;
  }

  .twl-hero {
    padding: 40px 16px;
  }
}

/* ── Search bar ─────────────────────────────────────── */
.twl-search-bar {
  position: relative;
  margin: 0 0 10px;
}

.twl-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 36px 9px 14px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #eee;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.twl-search-input::placeholder {
  color: #666;
}

.twl-search-input:focus {
  border-color: #666;
}

/* hide browser's built-in clear button */
.twl-search-input::-webkit-search-cancel-button { display: none; }

.twl-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.twl-search-clear:hover { color: #ccc; }

.twl-search-count {
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
}
