/* Avada Kedavra — mobile-first refinements.
   Loaded after style.css, journey.css, auth.css and admin-comunal.css.
   No images or large JS libraries: the iconography is lightweight inline SVG. */

:root { --mobile-dock-height: 68px; }
.mobile-dock { display: none; }

@media (max-width: 900px) {
  html { scroll-padding-top: 88px; }
  body { min-width: 0; padding-bottom: calc(var(--mobile-dock-height) + env(safe-area-inset-bottom, 0px)); }
  .container { max-width: 100%; }

  /* Compact heraldic header and a clear, accessible menu. */
  .header {
    position: sticky;
    top: 0;
    z-index: 60;
    background: rgba(14, 23, 17, .95);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 6px 25px #0003;
  }
  .header .brand { min-width: 0; }
  .header .brand > span:last-child { min-width: 0; }
  .menu-toggle {
    flex: 0 0 auto;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 72px;
    min-height: 44px;
    gap: 9px;
    padding: 8px 9px;
    border: 1px solid #bba37345;
    background: #bba3730c;
    color: #e6d5ad;
    font-size: 12px;
    letter-spacing: .04em;
  }
  .menu-toggle > span:last-child {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    line-height: 1;
    font-size: 20px;
  }
  .menu-toggle[aria-expanded="true"] { background: #bba37326; border-color: #bba37385; }
  .header nav:not(.mobile-dock) {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 65;
    max-height: calc(100dvh - 88px - var(--mobile-dock-height));
    overflow: auto;
    overscroll-behavior: contain;
    padding: 12px max(22px, env(safe-area-inset-right, 0px)) 24px;
    background: #172218;
    border-top: 1px solid #bba3732e;
    box-shadow: 0 22px 45px #000a;
  }
  .header nav:not(.mobile-dock) a {
    display: flex;
    align-items: center;
    min-height: 46px;
    border-bottom: 1px solid #bba37318;
    padding: 12px 7px;
    font-size: 14px;
    letter-spacing: .02em;
  }
  .header nav:not(.mobile-dock) .nav-enter {
    justify-content: space-between;
    width: 100%;
    margin-top: 10px;
    padding: 12px 16px;
    border: 1px solid #bba37390;
    background: #bba3731a;
  }
  .header nav:not(.mobile-dock) a[aria-current="page"] { color: #e6c58a; }

  /* Permanent illustrated navigation within thumb reach. */
  .mobile-dock {
    position: fixed;
    inset: auto 0 0;
    z-index: 90;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
    width: 100%;
    gap: 0;
    min-height: calc(var(--mobile-dock-height) + env(safe-area-inset-bottom, 0px));
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #bba37377;
    background: #111c16f5;
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    box-shadow: 0 -11px 32px #0008;
  }
  .mobile-dock .mobile-dock-link {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    min-height: 54px;
    padding: 5px 1px;
    color: #aeb6a1;
    text-align: center;
    font: 10px/1.15 Interface, Arial, sans-serif;
    letter-spacing: .012em;
    border-radius: 7px;
  }
  .mobile-dock-icon { width: 23px; height: 23px; flex: 0 0 auto; }
  .mobile-dock .mobile-dock-link.is-current {
    color: #efd49d;
    background: linear-gradient(180deg, #bba37326, #bba37309);
  }
  .mobile-dock .mobile-dock-link.is-current::before {
    content: '';
    position: absolute;
    top: -7px;
    width: 24px;
    height: 2px;
    background: #d3b77e;
    box-shadow: 0 2px 9px #d3b77e88;
  }
  .mobile-dock .mobile-dock-link:focus-visible { outline-offset: -2px; }
  .button, .library-filters button, .account-tabs button, .auth-tabs button,
  .timeline button, .subtle-button, .paper-link { min-height: 44px; }
  .button { max-width: 100%; }
  .eyebrow, .section-index span { overflow-wrap: anywhere; }
  .section-index::after {
    content: '✧';
    flex: 0 0 auto;
    margin-left: auto;
    color: #bba373a0;
    font: 16px/1 Editorial, Georgia, serif;
  }
}

@media (max-width: 640px) {
  :root { --mobile-dock-height: 68px; }
  html { scroll-padding-top: 80px; }
  .container { width: calc(100% - 36px); }
  .header { height: 72px; padding-inline: 18px; }
  .header nav:not(.mobile-dock) { max-height: calc(100dvh - 72px - var(--mobile-dock-height)); }
  .brand { letter-spacing: 1.25px; }
  .brand small { letter-spacing: 1.2px; line-height: 1.35; }
  .crest { flex: 0 0 auto; width: 35px; height: 42px; }
  .menu-toggle { min-width: 67px; }

  /* Preserve castle atmosphere without making the hero taller than needed. */
  .hero {
    min-height: max(620px, calc(100svh - 72px));
    background-position: 63% center;
  }
  .hero-content { padding-top: clamp(50px, 10vh, 90px); padding-bottom: 112px; }
  .hero h1 {
    font-size: clamp(58px, 16.3vw, 84px);
    line-height: .98;
    letter-spacing: -.038em;
    margin-top: 24px;
    overflow-wrap: normal;
  }
  .hero h1 em { margin-left: clamp(4px, 4vw, 16px); }
  .hero h2 { font-size: clamp(21px, 5.8vw, 26px); line-height: 1.27; }
  .hero-copy { max-width: 340px; font-size: 13px; }
  .ornament {
    display: flex;
    align-items: center;
    width: 150px;
    gap: 12px;
    margin: 24px 0 18px 3px;
    white-space: nowrap;
    font-size: 15px;
    letter-spacing: 5px;
  }
  .ornament::before, .ornament::after {
    content: '';
    height: 1px;
    flex: 1 1 auto;
    background: linear-gradient(90deg, transparent, #bba373b0);
  }
  .ornament::after { transform: rotate(180deg); }
  .hero-actions { align-items: flex-start; gap: 14px 18px; }
  .hero-actions .button { min-height: 48px; font-size: 12px; }
  .hero-actions .text-link { min-height: 44px; font-size: 12px; }
  .hero-bottom { bottom: 20px; gap: 12px; font-size: 8px; }
  .hero-bottom a { letter-spacing: .06em; }
  .hero-bottom > span { max-width: 47%; }

  /* All decorative motifs scale with the available area. */
  .section { padding-block: clamp(45px, 10vw, 62px); }
  .section-index { gap: 12px; margin-bottom: 24px; }
  .section-index span { font-size: 10px; letter-spacing: 1.2px; }
  .eyebrow { font-size: 10px; line-height: 1.6; }
  section h2 { font-size: clamp(33px, 9.8vw, 43px); }
  .world-copy p { font-size: 14px; }
  .quote p { font-size: clamp(20px, 5.4vw, 24px); }
  .paper-masthead { gap: clamp(7px, 2.4vw, 16px); }
  .paper-masthead h2 { font-size: clamp(26px, 7.7vw, 39px); letter-spacing: -.035em; }
  .paper-star { font-size: 13px; flex: 0 0 auto; }
  .paper-meta, .paper-subline { letter-spacing: .055em; font-size: 9px; }
  .news-side { grid-template-columns: 1fr; gap: 20px; }
  .news-side article + article { border-top: 1px solid #252a2233; padding-top: 20px; }
  .paper-aside { align-items: center; }
  .paper-aside .paper-label { font-size: 9px; }
  .house {
    min-width: 0;
    padding: 22px 11px 15px;
    overflow: hidden;
  }
  .house::after {
    content: '✦';
    position: absolute;
    top: 14px;
    right: 14px;
    pointer-events: none;
    font-size: 11px;
    color: var(--accent);
    opacity: .55;
  }
  .house-name { font-size: clamp(21px, 6.1vw, 26px); line-height: 1.1; }
  .house-mark { font-size: clamp(37px, 11vw, 48px); height: 72px; }
  .house-trait { font-size: 9px; letter-spacing: .06em; text-align: center; line-height: 1.6; }
  .house-foot { font-size: 10px; line-height: 1.45; }
  .hogwarts-caption, .hogwarts-caption .text-link { font-size: 10px; line-height: 1.6; }

  /* The year buttons become swipeable rather than unreadably compressed. */
  .timeline {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: #bba37377 transparent;
    -webkit-overflow-scrolling: touch;
  }
  .timeline button {
    flex: 0 0 clamp(96px, 28vw, 135px);
    scroll-snap-align: start;
    text-align: left;
    padding: 14px 5px 14px 2px;
  }
  .timeline button span { font-size: 26px; }
  .timeline button small { font-size: 9px; line-height: 1.4; letter-spacing: .045em; }
  .timeline-year { font-size: 56px; }
  .timeline-detail { min-height: 0; padding-bottom: 14px; }
  .invitation h2 { font-size: clamp(39px, 11vw, 54px); }
  .invitation-star { font-size: 29px; margin-bottom: 12px; }

  /* Decorative parchment stamps stay subtle instead of filling the screen. */
  .form-paper, .auth-paper { position: relative; }
  .form-paper::before {
    content: '✧';
    position: absolute;
    top: 10px;
    right: 14px;
    font: 15px/1 Editorial, Georgia, serif;
    color: #88734970;
    pointer-events: none;
  }
  .button:not(.gold):not(.danger-button) { background: #bba37311; color: var(--gold); }
  .form-paper .button:not(.gold):not(.danger-button),
  .auth-paper .button:not(.gold):not(.danger-button) {
    color: #53472d;
    border-color: #8a7855;
    background: #bba37316;
  }
  .form-paper .eyebrow { color: #675538; }
  .form-paper .admin-player { border-bottom-color: #29312330; }
  .form-paper .admin-player strong { color: #2c392b; }
  .form-paper .admin-player small { color: #646b5a; }
  .form-paper .admin-player p { color: #4f5c49; }
  .communal-chat .communal-compose small, .communal-chat .communal-empty { color: #546448; }

  /* Typography, forms and panels are legible and reachable on mobile. */
  .journey-heading { gap: 12px; }
  .journey-heading h1, .account-gate h1 { font-size: clamp(38px, 11vw, 52px); line-height: 1.09; overflow-wrap: anywhere; }
  .journey-heading p:not(.eyebrow) { font-size: 14px; }
  .form-paper, .auth-paper { padding: 22px 18px; min-width: 0; }
  .form-paper > h2, .auth-paper h2 { font-size: clamp(26px, 7.4vw, 32px); }
  .character-form label { font-size: 12px; }
  .character-form input, .character-form select, .character-form textarea,
  .auth-paper input, .reader-tools input, .admin-actions select, .admin-search input,
  .library-search input { font-size: 16px; min-height: 44px; max-width: 100%; }
  .account-tabs { gap: 8px; scroll-snap-type: x proximity; overflow-x: auto; }
  .account-tabs button {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 11px 12px 14px;
    font-size: 12px;
  }
  .auth-tabs { gap: 18px; }
  .auth-tabs button { padding: 10px 4px 15px; }
  .auth-story h1 { font-size: clamp(37px, 10vw, 45px); }
  .auth-paper { max-width: 100%; }
  .auth-perks { font-size: 13px; }
  .house-picker > div { gap: 9px; }
  .house-choice { padding: 14px 10px !important; min-width: 0; }
  .house-choice strong { font-size: 12px; }
  .house-choice small { font-size: 11px; }
  .wax-seal { width: 55px; height: 55px; font-size: 22px; }
  .character-medallion { width: 70px; height: 70px; font-size: 31px; }
  .character-card { grid-template-columns: 72px minmax(0, 1fr); gap: 0 14px; }
  .character-card h2 { font-size: 23px; }
  .character-card .eyebrow { font-size: 9px; }
  .badges .badge { padding: 19px 12px; }
  .badge h3 { font-size: 19px; }
  .badge p, .badge small { font-size: 11px; }
  .library-toolbar { flex-wrap: wrap; }
  .library-search { min-width: 0; }
  .library-toolbar > p { font-size: 10px; }
  .library-filters button { font-size: 11px; }
  .library-card-top, .library-card-foot { font-size: 10px; }
  .library-card > p { font-size: 13px; }
  .document-heading h1 { font-size: clamp(34px, 9.5vw, 44px); overflow-wrap: anywhere; }
  .document-paper { padding: 23px 18px; }
  .document-stamp { flex-wrap: wrap; gap: 8px 16px; font-size: 9px; }
  .document-body { font-size: 17px; line-height: 1.75; }
  .document-body table { font-size: 13px; }
  .reader-tools { display: block; }
  .reader-tools h2 { margin-top: 8px; }
  .reader-actions { display: grid; grid-template-columns: 1fr 1fr; margin: 14px 0; }
  .reader-actions .button { width: 100%; font-size: 10px; white-space: normal; }

  /* The new community chat and editorial dashboard respect narrow screens. */
  .admin-stats { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .admin-stats > div { padding: 17px 14px; min-width: 0; }
  .admin-stats > div:last-child { grid-column: 1 / -1; }
  .admin-stats strong { font-size: 29px; }
  .admin-stats span { font-size: 11px; line-height: 1.45; }
  .admin-tabs { flex-wrap: nowrap; gap: 4px; }
  .admin-tabs button { font-size: 12px; white-space: nowrap; }
  .admin-ui .journey-heading > .button { align-self: flex-start; }
  .admin-player { gap: 14px; min-width: 0; }
  .admin-player > div { min-width: 0; overflow-wrap: anywhere; }
  .admin-player strong { font-size: 14px; }
  .admin-player small { font-size: 12px; line-height: 1.65; }
  .admin-actions { display: flex; flex-wrap: wrap; }
  .admin-actions select { min-width: 0; width: 100%; }
  .admin-editor { padding: 20px 0; }
  .communal-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .communal-ui .journey-heading { display: flex; align-items: flex-start; }
  .communal-ui .journey-heading > div { min-width: 0; flex: 1; }
  .communal-ui .journey-heading h1 { font-size: clamp(35px, 9vw, 44px); }
  .communal-symbol { flex: 0 0 auto; font-size: 35px; line-height: 1; padding: 12px; border: 1px solid var(--house-glow, var(--gold)); border-radius: 50%; }
  .communal-chat { min-width: 0; }
  .communal-chat .form-paper { padding: 18px 14px; }
  .communal-chat-heading h2 { font-size: clamp(22px, 6.5vw, 29px); }
  .communal-chat-heading .button { min-height: 44px; }
  .communal-messages { height: min(45svh, 380px); min-height: 240px; padding: 16px 0; gap: 10px; }
  .communal-message { max-width: 100%; min-width: 0; padding: 13px 14px; }
  .communal-message p { font-size: 14px; line-height: 1.5; }
  .communal-compose > div { flex-wrap: wrap; gap: 10px; }
  .communal-compose .button { width: 100%; justify-content: center; }
  .house-welcome { gap: 11px; }
  .house-emblem { font-size: 33px; }
  .house-welcome h2 { font-size: 27px; }
  .danger-actions .button { min-width: min(100%, 180px); }

  /* Dialog must not disappear behind the fixed tab bar. */
  dialog { width: calc(100% - 24px); max-height: calc(100dvh - 110px - env(safe-area-inset-bottom, 0px)); padding: 22px 19px; }
  dialog h2 { font-size: clamp(28px, 7.5vw, 35px); }
  .footer { padding-bottom: 27px; }
  .footer .crest { width: 32px; height: 39px; }
}

@media (max-width: 375px) {
  .container { width: calc(100% - 28px); }
  .header { padding-inline: 13px; height: 68px; }
  .header .brand { gap: 7px; font-size: 12px; letter-spacing: .07em; }
  .header .brand small { font-size: 7px; letter-spacing: .07em; }
  .header .crest { width: 30px; height: 36px; font-size: 19px; }
  .header .crest span { font-size: 18px; }
  .menu-toggle { min-width: 52px; gap: 5px; padding-inline: 7px; }
  .menu-toggle-label { display: none; }
  .header nav:not(.mobile-dock) { max-height: calc(100dvh - 68px - var(--mobile-dock-height)); }
  .hero h1 { font-size: clamp(51px, 16vw, 61px); }
  .hero .eyebrow { letter-spacing: .06em; }
  .hero-bottom { font-size: 7px; }
  .paper-masthead h2 { font-size: clamp(24px, 7.2vw, 28px); }
  .paper-star { font-size: 10px; }
  .paper-masthead { gap: 6px; }
  .house { padding-inline: 8px; }
  .house-name { font-size: 20px; }
  .house-foot { gap: 6px; font-size: 9px; }
  .house-foot span { font-size: 13px; }
  .house-picker > div { grid-template-columns: 1fr; }
  .character-card { grid-template-columns: 65px minmax(0, 1fr); padding: 17px; gap: 0 9px; }
  .character-medallion { width: 60px; height: 60px; font-size: 26px; }
  .reader-actions { grid-template-columns: 1fr; }
  .mobile-dock { padding-inline: 4px; }
  .mobile-dock .mobile-dock-link { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-dock * { scroll-behavior: auto !important; transition: none !important; }
}
