/* v459 — desktop listing detail: use the wide pane instead of stretching
   hours and specials across it. Phone and in-app widths (<1024px) are unchanged.

   .dcol-main / .dcol-side / .dcol-links are wrappers added in app.js. On small
   screens they use display:contents so the DOM looks and lays out as it did
   before.

   Left column: name, status, hours, then crowd/extras and account actions.
   Right column: specials and events (2/3/4-wide). Quick Links stay under hours
   on the left at 2-wide and 3-wide layouts; at 1600px+ (4-wide) they move into
   the right column under Events, in two rows. */

.dcol-main,
.dcol-side,
.dcol-links {
  display: contents;
}

@media (min-width: 1024px) {
  /* Hours: Day | Bar | Kitchen sit close together, not 50/50 of the pane. */
  .detail .hours {
    width: max-content;
    max-width: 100%;
  }
  .detail .hhead,
  .detail .hrow {
    grid-template-columns: max-content max-content max-content;
    column-gap: 1.5rem;
  }
  .detail .hrow {
    padding: 4px 0;
  }

  /* Specials and events: each is its own row group. 2-wide on narrower desktops. */
  .detail .specials,
  .detail .events {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }
  .detail .spcard,
  .detail .evcard {
    flex: none;
    min-width: 0;
  }
}

@media (min-width: 1280px) {
  .detail .specials,
  .detail .events {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1600px) {
  /* 4-wide so all four special types, or four event types, fit on one row. */
  .detail .specials,
  .detail .events {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  body.split-detail #detailBody.dscroll {
    display: grid;
    grid-template-columns: minmax(16.5rem, 24rem) minmax(0, 1fr);
    grid-template-areas:
      "hero hero"
      "main side"
      "links side";
    column-gap: 28px;
    row-gap: 8px;
    align-items: start;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 16px 28px 40px;
  }

  body.split-detail #detailBody.dscroll > .dhero {
    grid-area: hero;
    max-height: 220px;
  }

  body.split-detail #detailBody.dscroll > .dcol-main,
  body.split-detail #detailBody.dscroll > .dcol-side,
  body.split-detail #detailBody.dscroll > .dcol-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
  }
  body.split-detail #detailBody.dscroll > .dcol-main { grid-area: main; }
  body.split-detail #detailBody.dscroll > .dcol-side { grid-area: side; align-self: start; }
  body.split-detail #detailBody.dscroll > .dcol-links { grid-area: links; }

  /* Crowd and actions live under hours in the narrower left column. */
  body.split-detail #detailBody.dscroll > .dcol-main .facts {
    grid-template-columns: 1fr;
  }
  body.split-detail #detailBody.dscroll > .dcol-main .footacts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  body.split-detail #detailBody.dscroll > .dcol-main .footacts .btn {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  /* 2-wide / 3-wide: Quick Links stay under hours, two buttons per row. */
  body.split-detail #detailBody.dscroll > .dcol-links .qlinks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  body.split-detail #detailBody.dscroll > .dcol-links .ql {
    flex: none;
    min-width: 0;
  }

  body.split-detail #detailBody.dscroll .section h3 {
    margin: 2px 0 6px;
  }
}

@media (min-width: 1600px) {
  /* 4-wide: Quick Links move under Events in the right column, two even rows. */
  body.split-detail #detailBody.dscroll {
    grid-template-columns: minmax(16.5rem, 22rem) minmax(0, 1fr);
    grid-template-areas:
      "hero hero"
      "main side"
      "main links";
  }
  body.split-detail #detailBody.dscroll > .dcol-links .qlinks {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }
  /* Split the buttons evenly across exactly two rows (6 → 3+3, 7 → 4+3). */
  body.split-detail #detailBody.dscroll > .dcol-links .qlinks:has(> .ql:nth-child(1):last-child) {
    grid-template-columns: minmax(0, 1fr);
  }
  body.split-detail #detailBody.dscroll > .dcol-links .qlinks:has(> .ql:nth-child(2):last-child),
  body.split-detail #detailBody.dscroll > .dcol-links .qlinks:has(> .ql:nth-child(3):last-child),
  body.split-detail #detailBody.dscroll > .dcol-links .qlinks:has(> .ql:nth-child(4):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body.split-detail #detailBody.dscroll > .dcol-links .qlinks:has(> .ql:nth-child(7):last-child),
  body.split-detail #detailBody.dscroll > .dcol-links .qlinks:has(> .ql:nth-child(8):last-child) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  body.split-detail #detailBody.dscroll > .dcol-links .qlinks:has(> .ql:nth-child(9):last-child),
  body.split-detail #detailBody.dscroll > .dcol-links .qlinks:has(> .ql:nth-child(10):last-child) {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* Restore the original phone/app stacking order when the wrappers flatten
   (display:contents). Specials and events go back under hours; crowd, actions
   and links follow them, same as before this layer. */
@media (max-width: 1023px) {
  #detailBody.dscroll > .dhero { order: 0; }
  #detailBody.dscroll > .dcol-main > .dident,
  #detailBody.dscroll > .dcol-main > .bigstatus,
  #detailBody.dscroll > .dcol-main > .dnote,
  #detailBody.dscroll > .dcol-main > .section.ownernote,
  #detailBody.dscroll > .dcol-main > .dlisting-acts,
  #detailBody.dscroll > .dcol-main > .section:has(> .hours) {
    order: 1;
  }
  #detailBody.dscroll > .dcol-side > .section:has(> .specials),
  #detailBody.dscroll > .dcol-side > .section:has(> .spempty),
  #detailBody.dscroll > .dcol-side > .section:has(> .events) {
    order: 2;
  }
  #detailBody.dscroll > .dcol-main > .section.crawl-sec,
  #detailBody.dscroll > .dcol-main > .section:has(> .facts),
  #detailBody.dscroll > .dcol-main > .footacts,
  #detailBody.dscroll > .dcol-links > .section:has(> .qlinks),
  #detailBody.dscroll > .dcol-links > .section.dsources,
  #detailBody.dscroll > .dcol-links > .dsrc-row {
    order: 3;
  }
}

/* v459 (Jon): app footer: Follow Open Late / Ko-fi on the left, directory badges as a tidy column on the right */
footer.foot.ol-foot-split{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:16px;align-items:start}
footer.foot.ol-foot-split > *{grid-column:1 / -1}
footer.foot.ol-foot-split > .foot-inner{grid-column:1}
footer.foot.ol-foot-split > .ol-dir-badges{grid-column:2;flex-direction:column;flex-wrap:nowrap;align-items:flex-end;justify-content:flex-start;gap:8px;margin:0;padding:6px 0 8px;max-width:none}

/* v459 (Jon): the New Year's Eve line sat in the header's first grid column ("brand") and stretched it to ~750px, squeezing and
   overlapping the State / County / City pickers at 900-1500px. Give it its own full-width row. */
@media (min-width: 760px) {
  header.top > .ol-nye-link { grid-column: 1 / -1; min-width: 0; max-width: 100%; }
  header.top > .ol-nye-link .nye-full { white-space: normal; }
}
