/* ========================================
   Nova on phones
   Loaded last. Everything here is scoped to phone widths except the hidden
   defaults, so the desktop layout is untouched.

   The model: a slim header (brand, search, messages, alerts), a bottom tab bar
   for the everyday paths, a "Participă" sheet listing every way to act, and the
   existing sidebar as the "Meniu" drawer with the full map of the site.
======================================== */

.otv-brand-app-preview { display: none; }

.mobile-tabbar,
.sidebar-theme-btn,
#mobile-post-back {
  display: none;
}

@media (max-width: 768px) {
  .nova-auth-modal .auth-close i { font-size: 20px; }
  .rd-refresh-btn i { font-size: 20px; }

  .measure-article-content {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  .voteaza-header { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
  .voteaza-header #voteaza-refresh { display: none; }
  #voteaza-active-grid { padding-top: 20px; }

  :root {
    --header-height: 58px;
    --mobile-tabbar-height: 62px;
    --mobile-bottom-space: calc(var(--mobile-tabbar-height) + env(safe-area-inset-bottom));
  }

  /* ---------- Header ---------- */
  .top-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.6rem;
    padding: 0 max(0.85rem, env(safe-area-inset-right)) 0 max(0.85rem, env(safe-area-inset-left));
  }

  /* The menu opens from the hamburger at the top left, beside the logo. */
  .top-header .mobile-menu-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin: 0 0.25rem 0 -0.5rem;
    padding: 0;
    border-radius: 50%;
    font-size: var(--fs-lg);
  }

  body[data-route^="video/"] #mobile-menu-btn { display: none; }
  body[data-route^="video/"] #mobile-post-back { display: grid; }
  .nova-square-page.is-post .otv-detail-header {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    border: 0;
  }
  .nova-square-page.is-post .otv-detail-back { display: none; }

  /* Phones show the full OTV logo, centred in the header, while search is
     switched off (common.css); with search on, hide it so the bar can take
     the whole header. */
  .top-header .logo {
    position: absolute;
    left: 50%;
    display: flex;
    transform: translateX(-50%);
  }

  /* Transparent gold lettering from the app artwork; export at 3x for sharpness. */
  .top-header .logo .otv-brand-logo {
    display: block;
    width: auto;
    height: 30px;
    max-width: 75px;
    object-fit: contain;
  }

  .top-header .logo .otv-brand-icon {
    display: none;
  }

  :root:not(.dark) .top-header .logo {
    align-items: center;
    justify-content: center;
    width: 102px;
    height: 44px;
  }

  /* The wordmark's look is defined once, in common.css (.otv-wordmark). */

  :root:not(.dark)[data-logo-preview="underline"] .top-header .logo::before {
    top: auto;
    right: 15px;
    bottom: 3px;
    left: 15px;
    height: 4px;
    border-radius: 999px;
    transform: skewX(-22deg) rotate(-3deg);
  }

  :root:not(.dark)[data-logo-preview="app-icon"] .top-header .logo::before,
  :root:not(.dark)[data-logo-preview="app-icon"] .top-header .logo .otv-brand-logo {
    display: none;
  }

  :root:not(.dark)[data-logo-preview="app-icon"] .top-header .logo .otv-brand-app-preview {
    display: block;
    border-radius: 9px;
  }

  #page-content > .home-page .otv-live-hero h1 {
    white-space: nowrap;
  }

  #page-content > .home-page .otv-live-hero .nova-live-badge {
    font-size: var(--fs-xs);
    white-space: nowrap;
  }

  .top-header .search-input {
    height: 38px;
    padding-top: 0;
    padding-bottom: 0;
    font-size: var(--fs-md); /* below 16px iOS zooms the page on focus */
  }

  /* The search bar stays open, filling the space between ☰ and the icons. */
  .top-header .header-center {
    display: flex;
    min-width: 0;
  }

  .top-header .search-container {
    width: 100%;
  }

  .top-header .search-shortcut {
    display: none;
  }

  .top-header .search-container:focus-within .search-input {
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  }

  .top-header .header-right {
    gap: 0.35rem;
  }

  .top-header .header-btn {
    width: 38px;
    height: 38px;
  }
  /* The account sits top right: an icon to sign in, or the member's picture. */
  .top-header #dark-mode-toggle[hidden] { display: none; }
  .header-account { display: contents; }
  .header-account-btn.is-member { overflow: hidden; padding: 0; text-decoration: none; }
  .header-account-btn .otv-user-avatar { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: grid; place-items: center; font-size: var(--fs-sm); }

  /* Pages do not zoom on phones (see the viewport tag); a double tap no longer
     zooms either. */
  html {
    touch-action: manipulation;
  }

  /* The theme switch sits in the header, as on desktop; the menu's labelled
     copy is hidden (its code stays in place). */
  .sidebar-footer .sidebar-theme-btn {
    display: none;
  }

  /* ---------- Room for the tab bar ---------- */
  .main-content {
    padding-bottom: var(--mobile-bottom-space);
  }

  .toast {
    bottom: calc(var(--mobile-bottom-space) + 0.75rem);
  }

  .nova-live-player.is-floating {
    right: 12px;
    bottom: calc(var(--mobile-bottom-space) + 12px);
    width: min(224px, calc(100vw - 24px));
  }

  #page-content:has(> .chat-page > .nova-chat) { padding: 0; }
  .nova-chat {
    height: calc(100dvh - var(--header-height) - var(--mobile-bottom-space));
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .nova-chat :is(.chat-threads-header, .chat-thread-header, .chat-debate-bar) { padding: 0.5rem 0.75rem; }
  .nova-chat .chat-thread-list { padding: 0.35rem 0.5rem; }
  .nova-chat .chat-thread-row-main { padding: 0.5rem 0.25rem; }
  .nova-chat .chat-thread-header { gap: 0.5rem; }
  .nova-chat .chat-messages { padding: 0.65rem; }
  .nova-chat .chat-message { max-width: 92%; padding: 0.5rem 0.65rem 0.35rem; }
  .nova-chat .chat-composer { padding: 0.5rem 0.65rem; }
  .nova-chat .chat-composer textarea { padding: 0.55rem 0.65rem; }

  /* ---------- Tab bar ---------- */
  .mobile-tabbar {
    position: fixed;
    z-index: 95;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    height: var(--mobile-bottom-space);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    border-top: 1px solid var(--border-light);
    background: color-mix(in srgb, var(--bg-card) 92%, transparent);
    backdrop-filter: saturate(1.6) blur(16px);
    -webkit-backdrop-filter: saturate(1.6) blur(16px);
    box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.06);
  }

  /* Detail pages carry their own bottom action bar and a back arrow. */
  body[data-route^="measure/"] .mobile-tabbar {
    display: none;
  }

  body[data-route^="measure/"] .main-content {
    padding-bottom: 0;
  }

  body:has(.measure-page-preview) .content-area {
    --measure-mobile-gutter: 1rem;
    padding-top: 0;
    padding-inline: var(--measure-mobile-gutter);
  }

  .measure-page-preview .measure-detail-title {
    margin-inline: calc(-1 * var(--measure-mobile-gutter));
    margin-bottom: 0;
    padding-inline: var(--measure-mobile-gutter);
    padding-top: calc(0.5rem + var(--measure-preview-top-gap));
    padding-bottom: 0.75rem;
  }

  .otv-feed-tabs.measure-preview-tabs.nova-live-controls { margin-top: 0.375rem; }

  .mobile-tab {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.35rem 0.15rem 0.3rem;
    border: 0;
    background: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-tab > i {
    height: 24px;
    display: grid;
    place-items: center;
    font-size: var(--fs-lg);
    line-height: 1;
  }

  .mobile-tab span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-tab.active,
  .mobile-tab[aria-expanded="true"] {
    color: var(--secondary);
  }

  .mobile-tab:active {
    transform: scale(0.94);
  }

  .mobile-tab:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: -4px;
    border-radius: 12px;
  }

  .mobile-tab-act-icon {
    width: 46px;
    height: 34px;
    display: grid;
    place-items: center;
    margin: 0;
    border-radius: 999px;
    background: #f4d046;
    color: #111827;
    box-shadow: 0 4px 12px rgba(234, 179, 8, 0.35);
    transition: transform 0.2s ease;
  }

  .mobile-tab-act-icon i {
    font-size: var(--fs-md);
  }

  .mobile-tab-act[aria-expanded="true"] .mobile-tab-act-icon {
    transform: rotate(45deg);
  }

  /* No label: the button sits in the middle of the bar's height. */
  .mobile-tab-act {
    justify-content: center;
    color: var(--text-primary);
  }

  /* ---------- Meniu drawer (the sidebar) ---------- */
  .sidebar {
    width: min(72vw, 270px);
    bottom: var(--mobile-bottom-space);
    border-radius: 0;
    box-shadow: 12px 0 40px rgba(15, 23, 42, 0.18);
  }

  .sidebar:not(.open) {
    box-shadow: none;
  }

  .sidebar-overlay {
    bottom: var(--mobile-bottom-space);
  }

  .sidebar .nav-section-title {
    display: block;
    margin: 0 0.35rem 0.45rem;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .sidebar .nav-item {
    min-height: 44px;
  }

  /* Nine categories read faster as a two-column grid than as a long list. */
  .nav-section-reforms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .nav-section-reforms .nav-section-title,
  .nav-section-reforms .nav-item[data-route="reforme"],
  .nav-section-reforms .nav-item[data-route="urmatoarele-reforme"] {
    grid-column: 1 / -1;
  }

  .nav-section-reforms .nav-item {
    margin: 0;
    gap: 0.5rem;
    padding: 0.55rem 0.6rem;
    font-size: var(--fs-sm);
  }

  .nav-section-reforms .nav-item:not([data-route="reforme"]):not([data-route="urmatoarele-reforme"]) {
    border: 1px solid var(--border-light);
  }

  .nav-section-reforms .nav-item span:not(.badge) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-section-reforms .nav-item .badge {
    padding: 0.1rem 0.4rem;
  }

  .sidebar .nav-section:first-child .nav-item {
    min-height: 42px;
    margin-bottom: 0.1rem;
  }

  .sidebar-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0.75rem 0.85rem;
  }

  .sidebar-footer .sidebar-account {
    grid-column: 1 / -1;
  }

  .sidebar-footer .sidebar-chat-btn {
    min-height: 44px;
    margin-bottom: 0;
    padding: 0 0.85rem;
  }

  .sidebar-theme-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    min-height: 44px;
    padding: 0 0.85rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
  }

  html.dark .sidebar-theme-btn i {
    color: var(--accent);
  }

  /* ---------- Homepage ---------- */
  #page-content > .home-page .dd-home-hero {
    gap: 1rem;
    margin-bottom: 0;
    padding: 1.25rem 1.15rem 1.15rem;
  }

  #page-content > .home-page .dd-home-hero h1 {
    font-size: var(--fs-xl);
    line-height: 1.08;
  }

  #page-content > .home-page .dd-home-hero .dd-hero-summary {
    font-size: var(--fs-md);
    line-height: 1.5;
  }

  #page-content > .home-page .dd-home-status {
    padding: 0.85rem 0.95rem;
  }

  /* The milestone title and meter stay; the full description is one tap away on the plan page. */
  #page-content > .home-page .dd-home-status [data-dd-slide-description] {
    display: none;
  }

  /* Its fixed height was sized for the description; titles wrap to two lines at most. */
  #page-content > .home-page .dd-home-slide {
    height: auto;
    min-height: 2.9rem;
  }

  #page-content > .home-page .dd-home-hero .dd-kicker {
    margin-bottom: 0.5rem;
  }

  #page-content > .home-page .dd-home-hero .dd-hero-actions {
    margin-top: 0.9rem;
  }

  #home-live {
    scroll-margin-top: calc(var(--header-height) + 0.75rem);
  }

  /* "Cum ajuți o propunere": compact rows instead of three tall centred cards. */
  .participation-grid {
    gap: 0.6rem;
  }

  .participation-card {
    display: grid;
    grid-template-columns: 44px 1fr;
    column-gap: 0.85rem;
    align-items: start;
    padding: 0.95rem;
    text-align: left;
  }

  .participation-card .participation-icon {
    grid-row: span 2;
    width: 44px;
    height: 44px;
    margin: 0;
    font-size: var(--fs-md);
  }

  .participation-card h3 {
    margin-bottom: 0.2rem;
  }

  #page-content > .home-page .participation-card p {
    font-size: var(--fs-sm);
  }

  .participation-section .section-header {
    text-align: left;
  }

  .homepage-manifesto .manifesto-text {
    font-size: var(--fs-md);
    line-height: 1.55;
  }
}

/* ---------- Phone fixes ---------- */
@media (max-width: 768px) {
  /* Știri: the desktop pull-up would tuck the category bar under the header. */
  .rd-page-header { margin-top: 0; }

  /* Menu: the theme switch takes the full row, like the account card under it. */
  .sidebar-footer .sidebar-theme-btn { grid-column: 1 / -1; white-space: nowrap; }

  /* Comunitatea OTV: tighter tabs right under the header. */
  .otv-feed-tabs [data-otv-tab],
  .otv-feed-tabs [data-profile-tab],
  .otv-feed-tabs .otv-feed-refresh { padding-block: 12px; }
  .nova-square-page .otv-compose-bar > .discussion-avatar { display: none; }

  /* Home: "OTV în direct" gets room under the header (24px in all). */
  #page-content > .home-page { padding-top: 12px; }

  /* Home section titles and their "see all" link share one line. */
  #page-content > .home-page .section-header { gap: 0.75rem; }
  /* Every home section title, "OTV în direct" included, shares one size, as on desktop. */
  #page-content > .home-page .section-header .section-title,
  #page-content > .home-page .leaderboard-column > .section-title,
  #page-content > .home-page .otv-live-hero h1 { min-width: 0; font-size: var(--fs-lg); }
  #page-content > .home-page .section-header .section-link { flex-shrink: 0; font-size: var(--fs-xs); white-space: nowrap; }
}

/* ---------- Feed rows on phones, laid out like Facebook ---------- */
/* The avatar sits on the name's line with the @username under the name and
   the time and ••• on the right; the text and the photo then use the whole
   width below, the photo running edge to edge. */
@media (max-width: 768px) {
  .otv-post > .otv-post-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0 10px;
    padding: 12px 12px 10px;
  }
  .otv-post > .otv-post-row > .otv-post-main { display: contents; }
  .otv-post-row > .otv-post-avatar { grid-column: 1; grid-row: 1; align-self: center; }
  .otv-post-avatar .otv-avatar { width: 46px; height: 46px; font-size: var(--fs-md); }
  .otv-post-main > :not(.otv-post-head) { grid-column: 1 / -1; }

  .otv-post-head {
    display: grid;
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    grid-template-columns: minmax(0, max-content) minmax(0, 1fr) auto auto;
    align-items: center;
    column-gap: 4px;
    font-size: var(--fs-md);
    line-height: 1.15;
  }
  .otv-post-head > .otv-post-name { grid-column: 1; grid-row: 1; min-width: 0; }
  .otv-post-head > .otv-post-handle { grid-column: 1 / -1; grid-row: 2; min-width: 0; margin-top: -1px; font-size: var(--fs-sm); line-height: 1.1; }
  .otv-post-head > .otv-muted:not(.otv-post-handle):not(.otv-time) { display: none; }
  .otv-post-head > .otv-time { grid-column: 3; grid-row: 1; font-size: var(--fs-sm); }
  /* The ••• tap target overhangs its row so it does not push the @username down. */
  .otv-post-head > .otv-post-menu { grid-column: 4; grid-row: 1; margin: -12px -4px -12px 2px; }

  .otv-post-text { margin-top: 10px; font-size: var(--fs-md); line-height: 1.45; }
  .otv-post-link-card {
    display: inline-flex;
    gap: 6px;
    width: fit-content;
    max-width: 100%;
    min-height: 34px;
    margin-top: 2px;
    padding: 4px 2px 4px 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--otv-gold-text);
  }
  .otv-post-link-icon,
  .otv-post-link-label small { display: none; }
  .otv-post-link-label { min-width: 0; }
  .otv-post-link-label strong { color: inherit; }
  .otv-post-link-card > i { flex: none; font-size: var(--fs-xs); }
  /* Photos and videos span the screen, square-edged, as on Facebook. */
  .otv-post-row .otv-post-media { width: auto; max-width: none; margin: 10px -12px 0; border: 0; border-radius: 0; }
  .otv-post-row .otv-post-media.is-image img { width: 100%; max-height: 560px; border-radius: 0; object-fit: contain; }
  /* A picture with no stored size holds a 4:3 box while it loads, so the
     posts below move less when it arrives. */
  .otv-post-row .otv-post-media.is-image:not(.is-sized) img:not(.is-loaded) { aspect-ratio: 4 / 3; }
  /* Size portrait media against the viewport with the browser bars visible,
     so scrolling does not resize the frame when those bars retract. */
  .otv-post-row .otv-post-media.is-portrait { --otv-portrait-height: min(55vh, 460px); }
  @supports (height: 1svh) {
    .otv-post-row .otv-post-media.is-portrait { --otv-portrait-height: min(55svh, 460px); }
  }
  .otv-post-row .otv-post-media.is-video.is-portrait {
    --otv-portrait-height: min(46vh, 380px);
    width: min(76%, calc(var(--otv-portrait-height) * var(--otv-video-ratio, .5625)));
    height: auto;
    margin-inline: 0;
    border-radius: 12px;
    aspect-ratio: var(--otv-video-ratio, .5625);
  }
  @supports (height: 1svh) {
    .otv-post-row .otv-post-media.is-video.is-portrait { --otv-portrait-height: min(46svh, 380px); }
  }
  .otv-post-row .otv-post-media.is-image.is-portrait { width: fit-content; max-width: 76%; margin-inline: 0; border-radius: 12px; }
  .otv-post-row .otv-post-media.is-image.is-portrait img { width: auto; max-width: 100%; height: auto; max-height: var(--otv-portrait-height); object-fit: contain; }
  .otv-post-row .otv-post-media.is-video.is-portrait video,
  .otv-post-row .otv-post-media.is-video.is-portrait .otv-video-cover img { object-fit: cover; }
  .otv-post-actions { max-width: none; margin-top: 8px; }
  .otv-post-actions > button,
  .otv-post-actions .otv-post-menu-button { min-width: 44px; min-height: 44px; justify-content: center; }
  /* The circle stays round; an invisible 44px area around it takes the tap. */
  .rd-news-meta .rd-summary-btn { position: relative; width: 22px; height: 22px; flex: 0 0 22px; }
  .rd-news-meta .rd-summary-btn::after { content: ""; position: absolute; inset: -11px; }
}

@media (max-width: 480px) {
  body:has(.measure-page-preview) .content-area { --measure-mobile-gutter: 0.75rem; }
}

@media (max-width: 360px) {
  .mobile-tab span { font-size: 10px; letter-spacing: 0; }
}

/* ---------- Profile on phones: the same edge-to-edge feed as Comunitatea ---------- */
@media (max-width: 768px) {
  body:has(.community-profile-page) .content-area { padding-inline: 0; }
  .community-profile-v2 .community-profile-primary .community-profile-hero,
  .community-profile-v2 .community-profile-skeleton-hero { border-inline: 0; border-radius: 0; }
  .community-profile-v2 .community-profile-cover { border-radius: 0; }
  /* The stats column belongs to the desktop's right side; phones show the profile and posts only. */
  .community-profile-v2 .community-profile-rail { display: none; }
  /* The tabs follow the header directly: no gap, one line between them. */
  .community-profile-v2 .community-profile-layout { row-gap: 0; }
  .community-profile-v2 .community-profile-primary .community-profile-stream { border-top: 0; }
}

/* ---------- No page footer on phones ---------- */
/* It flashed up between the header and the tab bar while any page loaded. Its
   links are in Setări › Informații Legale. */
@media (max-width: 768px) {
  body .site-footer-simple { display: none; }
}

/* Profiles on phones: the cover starts right under the top bar. */
@media (max-width: 768px) {
  #page-content:has(> .community-profile-page) { padding-top: 0; }
}

/* Phones: the live broadcast title one step smaller, so it reads as a caption under the player. */
@media (max-width: 768px) {
  .nova-live-content h3 { font-size: var(--fs-md); line-height: 1.35; }
  .otv-live-hero .nova-live-content { padding-bottom: 1rem; }
  .otv-live-hero .nova-live-content > p { margin-bottom: 0; }
}
