/* ==========================================================================
   Churchwide: DESKTOP LAYOUT
   --------------------------------------------------------------------------
   The app is designed for phones first (src/styles.css). This file only
   adds rules for wide screens (computers and large tablets). On a phone
   none of it applies, so editing it can't break the phone layout.

   HOW TO MAKE A CHANGE
   1. Most changes are one number in "SETTINGS" just below.
   2. To try something live: open the app in Chrome, right-click → Inspect,
      click <html> in the Elements panel, and edit a --desk-... value under
      "Styles". The page updates instantly. Copy the value you like here.
   3. Save, push to GitHub (main). Cloudflare Pages publishes in about a
      minute. Then run `node scripts/build.mjs` (or ask whoever usually
      does) so the /demo/ copy picks it up too.

   WHEN DOES DESKTOP KICK IN?
   When the window is at least 1024px wide (see the two "@media" lines
   below: change 1024 / 1400 there if you want a different cut-off;
   CSS doesn't allow a setting to be used in that spot).
   ========================================================================== */

:root {
  /* ---------- SETTINGS ---------- */
  --desk-sidebar: 240px;        /* width of the left menu that replaces the bottom tab bar */
  --desk-content: 860px;        /* widest the main column gets on a normal laptop */
  --desk-content-wide: 1080px;  /* ...and on a big monitor (1400px+ wide) */
  --desk-editor: 1200px;        /* staff screens that ask for extra room (Service Schedule) */
  --desk-calendar: 1600px;      /* Calendar → Month: as wide as the window allows, up to this */
  --desk-side-pad: 32px;        /* space between the menu and the content */
  --desk-cards: 2;              /* announcements / news cards side by side (laptop) */
  --desk-cards-wide: 3;         /* ...and on a big monitor */
  --desk-tiles: 4;              /* tiles per row on the More page (phone has 3) */
  --desk-carousel-cards: 2;     /* cards showing at once in the My Church carousel */
  --desk-dialog: 560px;         /* width of pop-ups (on phones they slide up from the bottom) */
  --desk-chat-height: 62vh;     /* height of a group chat's message area */
}

/* ===== Laptop and larger ================================================ */
@media (min-width: 1024px) {

  /* --- Page frame: menu on the left, content centred in the rest -------- */
  .app {
    max-width: none; margin: 0; box-shadow: none;
    padding-left: var(--desk-sidebar);
  }
  html.wide-editor .app { max-width: none; }
  .app-main {
    max-width: calc(var(--desk-content) + 2 * var(--desk-side-pad));
    margin: 0 auto;
    padding: 8px var(--desk-side-pad) 64px;
  }
  html.wide-editor .app-main { max-width: calc(var(--desk-editor) + 2 * var(--desk-side-pad)); }
  html.cal-wide .app-main { max-width: calc(var(--desk-calendar) + 2 * var(--desk-side-pad)); }   /* Calendar → Month */

  /* --- Left menu (the phone's bottom tab bar, turned on its side) ------- */
  .tabbar {
    top: 0; bottom: 0; left: 0; transform: none;
    width: var(--desk-sidebar); max-width: none;
    display: flex; flex-direction: column; gap: 4px;
    padding: 20px 14px; border-top: 0; border-right: 1px solid var(--line);
    overflow-y: auto;
  }
  .tab-brand {
    display: block;
    font: 600 22px/1.2 var(--font-display); color: var(--navy);
    padding: 4px 12px 18px; letter-spacing: -.01em;
  }
  :root[data-theme="dark"] .tab-brand { color: var(--gold-bright); }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tab-brand { color: var(--gold-bright); } }
  .tab {
    height: auto; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 11px 14px; border-radius: 10px;
    font-size: 15px; font-weight: 600; text-align: left;
  }
  .tab:not(:disabled):hover { background: var(--info-soft); color: var(--ink); }
  .tab.is-on { background: var(--info-soft); }
  .tab.is-on .tab-icon::after { display: none; }   /* the small gold dot is a phone cue */

  /* --- Things that floated above the bottom tab bar now sit lower ------- */
  .toast { bottom: 28px; left: calc(50% + var(--desk-sidebar) / 2); }
  .help-bubble-wrap { bottom: 28px; right: 28px; }
  .update-banner { left: calc(var(--desk-sidebar) + 24px); right: 24px; bottom: 28px; }
  .sticky-actions { bottom: 0; }

  /* --- Pop-ups: centred dialogs instead of sheets sliding up ------------ */
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet {
    max-width: var(--desk-dialog); border-radius: 18px;
    max-height: calc(100vh - 48px); overflow-y: auto;
    padding: 22px 26px 24px;
  }
  .sheet-grip { display: none; }

  /* --- Cards side by side ---------------------------------------------- */
  .ann-rows, .ann-list {
    display: grid; align-items: start; gap: 14px;
    grid-template-columns: repeat(var(--desk-cards), minmax(0, 1fr));
  }
  .carousel .ann-card { flex-basis: calc((100% - (var(--desk-carousel-cards) - 1) * 12px) / var(--desk-carousel-cards)); }
  .more-grid { grid-template-columns: repeat(var(--desk-tiles), minmax(0, 1fr)); }

  /* --- Group chat: use the screen's height ----------------------------- */
  .chat-log { max-height: var(--desk-chat-height); }

  /* --- Mouse niceties (phones have no hover) ---------------------------- */
  .ann-row, .coming-up, .row-link, .chat-row { transition: border-color .15s, box-shadow .15s; }
  .ann-row:hover, button.coming-up:hover, .row-link:hover {
    border-color: color-mix(in srgb, var(--ink) 22%, var(--line));
    box-shadow: 0 2px 4px rgba(23, 36, 58, .07), 0 8px 22px rgba(23, 36, 58, .08);
  }
  .btn-outline:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
  .btn-primary:not(:disabled):hover { filter: brightness(1.08); }
  .chip:hover:not(.is-on) { color: var(--ink); }

  /* --- Long text stays readable ----------------------------------------- */
  .news-body, .news-lede { max-width: 68ch; }
}

/* ===== Big monitor ======================================================== */
@media (min-width: 1400px) {
  .app-main { max-width: calc(var(--desk-content-wide) + 2 * var(--desk-side-pad)); }
  .ann-rows, .ann-list { grid-template-columns: repeat(var(--desk-cards-wide), minmax(0, 1fr)); }
}

/* The "Churchwide" name at the top of the left menu is only for desktop. */
@media (max-width: 1023.98px) { .tab-brand { display: none; } }

/* Printing uses the phone layout (styles.css handles print). */
/* Mission Search and the Bible on a computer: more cards across; the Bible text stays a comfortable reading width. */
@media (min-width: 900px) {
  .ms-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .ms-top { height: 130px; }
  .bible-text { max-width: 720px; margin: 0 auto; }
  .bible-sel-bar { bottom: 16px; max-width: 720px; margin: 0 auto; }
  .bible-books { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* More → My Blocks on a computer: keep the blocks narrow and put 3 or 4 across instead of stretching 2. */
@media (min-width: 900px) {
  .half-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
@media (min-width: 1400px) {
  .half-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media print {
  .app { padding-left: 0 !important; }
  .tabbar { display: none !important; }
}

/* Fewer full-width buttons on wide screens: buttons sitting directly on a page, and the
   buttons under an announcement or story, are only as wide as their words. */
@media (min-width: 1024px) {
  .item-actions { flex-direction: row; flex-wrap: wrap; }
  .item-actions > .btn { width: auto; }
  .screen-body > .btn, .screen-body > a.btn, .screen-body > .btn-block, .screen-body > .stack > .btn,
  .screen-body .stack > .btn-block, .screen-body > .row-link.archive-link { align-self: flex-start; width: auto; min-width: 240px; }
  .page-chip { width: auto; max-width: 420px; }
}

/* Prepare Bulletin: each pinned item or announcement is a full card with its buttons under it, two across. */
@media (min-width: 900px) {
  .create-bulletin .cb-pins, .create-bulletin .cb-anns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
  .create-bulletin .cb-pin > .ann-rows, .create-bulletin .cb-pin > .ann-list,
  .create-bulletin .cb-ann > .ann-rows, .create-bulletin .cb-ann > .ann-list { display: block; }
  .create-bulletin .cb-pin, .create-bulletin .cb-ann { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
  .create-bulletin .cb-unpin { align-self: flex-start; }
}
