/* Sharing (docs/SPEC.md §4.9, §5): the Share dialog, and the page a shared link opens.
   Every colour is one of app.css's properties, so both themes and every accent follow. */

/* --- the Share dialog ---------------------------------------------------------------------- */

.share-dialog { width: min(32rem, calc(100% - 2rem)); }
.share-dialog.busy { cursor: progress; }
.share-dialog.busy .button { pointer-events: none; opacity: 0.7; }
.share-section { display: grid; gap: 0.55rem; }
.share-heading { display: flex; align-items: center; gap: 0.45rem; margin: 0.4rem 0 0; font-size: var(--text-m); color: var(--text-strong); }
.share-heading .icon { width: 1.1rem; height: 1.1rem; color: var(--muted); }
.share-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.share-person { display: flex; align-items: center; gap: 0.6rem; min-height: 2.6rem; }
.share-avatar {
  display: grid; place-items: center; flex: none;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--accent-container); color: var(--accent-container-text); font-weight: 600; font-size: var(--text-s);
}
.share-who { display: grid; flex: 1; min-width: 0; }
.share-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-s); color: var(--text); }
.share-status, .share-print { font-size: var(--text-xs); color: var(--muted); }
.share-print { font-family: ui-monospace, monospace; letter-spacing: 0.02em; }
.share-add { display: flex; gap: 0.5rem; }
.share-add input, .share-url {
  flex: 1; min-width: 0; min-height: 2.1rem; padding: 0 0.6rem;
  border: 1px solid var(--grid-line); border-radius: 8px; background: var(--field-bg); color: var(--text); font: inherit; font-size: var(--text-s);
}
.share-url { width: 100%; box-sizing: border-box; color: var(--muted); }
.share-warning { margin: 0; font-size: var(--text-xs); line-height: 1.45; color: var(--muted); }
.share-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.share-buttons .icon, .share-person .button .icon, .share-wiki .icon { width: 1rem; height: 1rem; margin-right: 0.3rem; }
.share-end { margin-top: 0.6rem; }
.share-wiki { justify-self: start; }
.note-shared { display: inline-flex; color: var(--muted); }
.note-shared .icon { width: 0.95rem; height: 0.95rem; }
.history-author { color: var(--muted); }

/* --- a shared link's page --------------------------------------------------------------------- */

.shared-app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.shared-app.shared-alone { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); } /* a booking page: no sidebar */
/* Its page last on the screen, clear of a phone's home indicator (the sidebar padded for it before). */
.shared-alone .shared-event { padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px)); }
.shared-side { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.shared-side-title:has(+ #shared-list:empty) { display: none; }
.shared-event .shared-side-title { margin: 0 0 0.3rem; }
.shared-side .brand { color: var(--text-strong); text-decoration: none; display: flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.shared-side-title { margin: 0.6rem 1.1rem 0.3rem; font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.shared-side .sections { padding: 0 0.5rem; }
.shared-side .side-item { text-decoration: none; }
.shared-side .side-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The camel centered under what was shared (a row of its own in the note's scroller, as the stats line); its click opens "Like Diffa?" in the dialog. */
.shared-brand-row { flex: 0 0 100%; display: flex; justify-content: center; padding-top: 2.5rem; }
.shared-brand { position: relative; display: inline-flex; padding: 0.5rem; border: 0; border-radius: 999px; background: var(--transparent); cursor: pointer; }
.shared-brand .brand-mark { width: 40px; height: 40px; }
.shared-brand .brand-eye { fill: var(--editor-bg); }
/* The hover's tint laid over the camel, not behind it: the eye, the page's colour, is tinted as the circle is. */
.shared-brand::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--transparent); pointer-events: none; }
@media (hover: hover) { .shared-brand:hover::after { background: var(--accent-tint); } }
.subscribe-card { font-size: var(--text-s); line-height: 1.45; color: var(--text); }
.subscribe-card p { margin: 0; }
.subscribe-migrate { margin-top: 0.3rem !important; font-weight: 600; color: var(--muted); }
.subscribe-sources { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0; padding: 0; list-style: none; }
.subscribe-sources li { padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--accent-container); color: var(--accent-container-text); font-size: var(--text-xs); }

.shared-main { display: flex; flex-direction: column; min-height: 0; }
.shared-head { gap: 0.6rem; padding: 0.9rem 1.25rem 0.5rem; }
.shared-heading { min-width: 0; }
.shared-title { margin: 0; font-size: var(--text-l); color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared-byline { margin: 0.15rem 0 0; font-size: var(--text-s); color: var(--muted); }
.shared-me { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--text-s); color: var(--muted); }
.shared-me .icon { width: 1rem; height: 1rem; }
.shared-body { flex: 1; min-height: 0; }
.shared-joining { margin: auto; color: var(--muted); }
.shared-gone { margin: auto; display: grid; justify-items: center; gap: 0.8rem; max-width: 26rem; padding: 2rem 1rem; text-align: center; }

.shared-reminders { overflow-y: auto; padding: 0.5rem 1.25rem 2rem; }
.shared-items { list-style: none; margin: 0; padding: 0; }
.shared-item { display: flex; align-items: center; gap: 0.6rem; min-height: 2.4rem; }
.shared-item input[type="checkbox"] { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; margin: 0; }
.shared-item-text { flex: 1; min-width: 0; border: 0; background: var(--transparent); color: var(--text); font: inherit; padding: 0.3rem 0; }
.shared-item-text:focus { outline: none; }
.shared-plus { display: inline-flex; color: var(--muted); }
.shared-plus .icon { width: 1.1rem; height: 1.1rem; }
.shared-done { margin-top: 1rem; color: var(--muted); }
.shared-done summary { cursor: pointer; font-size: var(--text-s); }
.shared-done .shared-item-text { color: var(--muted); text-decoration: line-through; }

.shared-history { width: min(40rem, calc(100vw - 2rem)); box-sizing: border-box; }
.shared-versions { list-style: none; margin: 0; padding: 0; max-height: 14rem; overflow-y: auto; }
.shared-version-text { margin: 0; max-height: 40vh; overflow: auto; white-space: pre-wrap; font: inherit; font-size: var(--text-s); color: var(--text); }
.shared-version-text:empty { display: none; }

@media (max-width: 700px), (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) { /* a phone, upright or on its side (app.css) */
  /* A phone: the note fills the screen, the sidebar (the links opened here) follows below it as the page scrolls. */
  .shared-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(70dvh, auto) auto; height: auto; min-height: 100dvh; overflow: visible; }
  .shared-side { order: 2; overflow: visible; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .shared-head { padding: 0.75rem 1rem 0.4rem; }
}

/* --- Import from other apps (SPEC §5) -------------------------------------------------------- */

.import-options { display: grid; gap: 0.6rem; }
.import-sources summary { cursor: pointer; font-size: var(--text-s); color: var(--accent); }
.import-sources dl { margin: 0.5rem 0 0; max-height: 14rem; overflow-y: auto; font-size: var(--text-s); line-height: 1.45; }
.import-sources dt { margin-top: 0.5rem; font-weight: 600; color: var(--text); }
.import-sources dd { margin: 0.1rem 0 0; color: var(--muted); }

/* An event's link page, and its Share button in the event editor (SPEC §4.9 Invitees). */
.shared-event { overflow-y: auto; padding: 0.5rem 1.25rem 2rem; display: grid; gap: 0.9rem; align-content: start; }
.shared-when { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: var(--text-m); color: var(--text); }
.shared-when .icon { width: 1.2rem; height: 1.2rem; color: var(--muted); }
.shared-where, .shared-notes { margin: 0; color: var(--text); white-space: pre-wrap; }
.shared-event .shared-item { justify-content: space-between; }
.cal-invitees-title { display: flex; align-items: center; justify-content: space-between; }
.cal-share { width: 1.9rem; height: 1.9rem; }
.cal-share .icon { width: 1.05rem; height: 1.05rem; }

/* --- booking pages (SPEC §3.10, §5): Settings > Booking Pages, and the page a booking link opens -- */

/* A page's screen drawn as the event editor (.calendar-panel, app.css): centred in Settings as its
   other screens, the table's stuck hours on the editor's own surface. Each field its name, a line
   saying what it does, then the control the row's full width. */
.calendar-panel.booking-editor { --list-bg: var(--event-editor-bg); margin: 0.5rem auto; }
.booking-section { display: grid; gap: 0.9rem; min-width: 0; }
.booking-rule, .booking-switch { display: grid; gap: 0.3rem; min-width: 0; }
/* Days of their own under the week (§5): each its date and hours (or Closed), a cross removing it. */
.booking-dates { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.booking-date { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: var(--text-s); }
.booking-hint { margin: 0; font-size: var(--text-xs); color: var(--muted); line-height: 1.35; }
/* Up to 2000 characters: it scrolls past half the screen (app.css's .cal-notes hides what overflows,
   the event editor's growing to fit, which this one doesn't). */
.booking-editor .cal-notes { min-height: 4.5rem; max-height: 50vh; overflow-y: auto; padding-block: 0.6rem; resize: vertical; }
/* On a phone the whole screen, as the event editor (app.css's .calendar-panel there): no margin, no
   Settings column's width on its side. */
@media (max-width: 700px), (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) {
  .calendar-panel.booking-editor { margin: 0; max-width: none; }
}
/* The week's table (§5): 07:00 to 20:00 (or more, --rows hours, booking-pages.js), wider than a phone's
   screen, never taller than an upright one, the hours stuck on the left as a swipe scrolls the days; a
   tap opens or closes a cell. */
.booking-grid-scroll {
  --hour-col: 4rem;
  --row: clamp(2.4rem, calc((100dvh - 15rem) / (var(--rows, 13) + 1)), 3.25rem);
  /* isolation: its stuck hours over its cells, never over the editor's floating foot. */
  min-width: 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; isolation: isolate;
  border-radius: 16px; background: var(--list-bg);
  scroll-padding-inline-start: var(--hour-col); scrollbar-width: thin;
}
.booking-grid {
  display: grid; grid-template-columns: var(--hour-col) repeat(7, minmax(5rem, 1fr));
  grid-template-rows: 2rem repeat(var(--rows, 13), var(--row));
  width: max-content; min-width: 100%; /* as wide as its days, so the hours stay stuck all the way across */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.booking-grid-corner, .booking-grid-hour { position: sticky; left: 0; z-index: 3; background: var(--list-bg); } /* over a focused cell's ring (2) as it scrolls under */
.booking-grid-day {
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-s); font-weight: 600; color: var(--muted); text-transform: capitalize;
}
.booking-grid-hour {
  display: flex; align-items: center; justify-content: flex-end; padding-right: 0.5rem;
  font-size: var(--text-m); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.booking-cell {
  /* No gap between the cells (a day scrolled under the hours would show in it): a clear border apart. */
  min-width: 0; padding: 0; border: 2px solid transparent; border-radius: 6px; background-clip: padding-box;
  background: var(--fill, none) padding-box, var(--field-bg-quiet) padding-box;
  cursor: pointer; /* touch-action: the scroller's, below */
  -webkit-tap-highlight-color: transparent; /* the green is the tap's answer */
  transition: background-color 0.15s;
}
.booking-cell[aria-pressed="true"] { background: var(--success) padding-box; }
/* A swipe pans the days sideways, and no double-tap zoom eats a second tap: over the Android
   app's Settings, whose every element pans only up and down (app.css, .shell-android). */
.booking-grid-scroll, .booking-grid-scroll *,
.shell-android .settings-pane :is(.booking-grid-scroll, .booking-grid-scroll *) { touch-action: pan-x pan-y pinch-zoom; }
.booking-cell:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; position: relative; z-index: 2; }

.booking-link-part { display: grid; gap: 0.5rem; }
.booking-link { color: var(--muted); }
.booking-link-part .button .icon { width: 1rem; height: 1rem; margin-right: 0.3rem; }

.booking-page { gap: 0.7rem; }
.booking-week-nav { display: flex; align-items: center; gap: 0.5rem; }
.booking-week { font-weight: 600; color: var(--text-strong); }
.booking-prev .icon { transform: rotate(180deg); }
.booking-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.5rem; }
.booking-day { min-width: 0; }
.booking-day-head { margin: 0 0 0.35rem; font-size: var(--text-s); font-weight: 600; color: var(--muted); text-transform: capitalize; }
.booking-day-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.booking-slot { width: 100%; justify-content: center; }
.booking-busy {
  padding: 0.35rem 0.5rem; border-radius: 8px; background: var(--field-bg-quiet);
  font-size: var(--text-xs); color: var(--muted); overflow-wrap: anywhere;
}
.booking-mine { gap: 0.5rem; flex-wrap: wrap; }
.booking-mine-when { flex: 1; min-width: 12rem; }

@media (max-width: 700px), (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) { /* a phone (app.css) */
  /* The days one list, each its times in a row that wraps. */
  .booking-days { grid-template-columns: minmax(0, 1fr); gap: 0.9rem; }
  .booking-day-items { grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); }
  .booking-busy { grid-column: 1 / -1; }
}
