/* eventmgr styles. Fonts and colours follow portal.nclgreens.org.uk (SPEC V1); variable names
   match the portal's so the two can share a stylesheet later. */

/* Self-hosted fonts (SIL Open Font Licence, see assets/fonts/OFL-*.txt), latin + latin-ext
   subsets as on the portal, so members' browsers never contact Google. */
@font-face {
  font-family: 'Manrope'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/assets/fonts/manrope-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Manrope'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/assets/fonts/manrope-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Bebas Neue'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/assets/fonts/bebas-neue-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Bebas Neue'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/assets/fonts/bebas-neue-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --gc-green: #00a85a;       /* Green Party primary: accents and borders, never under white text */
  --gc-green-dark: #00643b;   /* headings, links, primary buttons */
  --gc-green-hover: #004d2e;
  --gc-green-active: #003d24;
  --gc-green-light: #e6f7f0;  /* panels, placeholder tiles */
  --gc-on-dark: #a8e6c8;
  --gc-muted: #5a636b;
  --text: #1f2933;
  --page-bg: #f8f9fa;
  --surface: #ffffff;
  --border: #d5dbd8;
  --danger: #b3261e;
  --rsvp-none: #1a4fd6;
  --rsvp-yes: #00a85a;
  --rsvp-no: #b3261e;
  --rsvp-maybe: #ffe45c;
  --font-body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Bebas Neue', 'Arial Narrow', sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--page-bg);
}

/* One phone-width column, centred on larger screens. */
.app {
  max-width: 30rem;
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem;
  background: var(--surface);
}

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--gc-green-dark);
  line-height: 1.1;
  margin: 0 0 0.5rem;
}

.screen-title { font-size: 2.5rem; margin: 0; }
h2 { font-size: 1.75rem; }

a { color: var(--gc-green-dark); }
a:hover { color: var(--gc-green-hover); }

:focus-visible {
  outline: 3px solid var(--gc-green-dark);
  outline-offset: 2px;
}

.muted { color: var(--gc-muted); }
.small { font-size: 0.9rem; }

/* Buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.5rem 1.1rem;
  border: 2px solid transparent;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary { background: var(--gc-green-dark); border-color: var(--gc-green-dark); color: #fff; }
.btn-primary:hover { background: var(--gc-green-hover); border-color: var(--gc-green-hover); color: #fff; }
.btn-primary:active { background: var(--gc-green-active); border-color: var(--gc-green-active); }

.btn-outline { background: #fff; border-color: var(--gc-green-dark); color: var(--gc-green-dark); }
.btn-outline:hover { background: var(--gc-green-dark); color: #fff; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1e18; border-color: #8f1e18; color: #fff; }

.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.6; cursor: default; }

/* Forms --------------------------------------------------------------- */

.stack { display: flex; flex-direction: column; gap: 0.6rem; }

label { font-weight: 600; }

input[type="text"], input[type="email"], input[type="date"], input[type="time"], textarea {
  width: 100%;
  min-height: 52px;
  padding: 0.6rem 0.75rem;
  border: 1px solid #9aa5a0;
  border-radius: 6px;
  font: inherit;
  font-size: 1.1rem;
  color: var(--text);
  background: #fff;
}

.code-input {
  font-size: 2rem !important;
  font-weight: 600;
  letter-spacing: 0.4em;
  text-align: center;
  padding-left: 0.4em;
}

/* Panels and messages -------------------------------------------------- */

.panel {
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid var(--border);
  border-top: 4px solid var(--gc-green);
  border-radius: 0.5rem;
}

.alert { padding: 0.6rem 0.8rem; border-radius: 6px; margin: 0 0 0.8rem; }
.alert-info { background: var(--gc-green-light); color: var(--gc-green-dark); }
.alert-error { background: #fbe9e7; color: #8f1e18; }

/* Login ---------------------------------------------------------------- */

.page-login .app { padding-top: 2rem; }
.login .muted { margin-top: 0.25rem; }

/* Screen header ---------------------------------------------------------- */

.screen-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1.5px solid var(--text);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--gc-green-dark); color: var(--gc-green-dark); }

/* Events Overview ---------------------------------------------------------- */

.overview { padding-bottom: 6rem; }   /* room above the bottom bar */

.event-group { margin-top: 1.25rem; }

.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid #9aa5a0;
  margin-bottom: 0.25rem;
}
.group-head h2 { margin: 0; }
.going-label { font-family: var(--font-head); font-size: 1.5rem; letter-spacing: 0.03em; color: var(--text); }

.event-list { list-style: none; margin: 0; padding: 0; }

.event-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
}

.event-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
}
.event-link:hover .event-title { color: var(--gc-green-dark); text-decoration: underline; }

.thumb {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 4px;
  object-fit: cover;
}
.thumb-placeholder { display: block; background: var(--gc-green-light); border: 2px solid var(--gc-green); }

.event-text { min-width: 0; display: flex; flex-direction: column; }
.event-title { font-weight: 700; font-size: 0.92rem; line-height: 1.25; overflow-wrap: anywhere; }
.event-when { color: var(--gc-muted); font-size: 0.8rem; }

.empty { margin-top: 2rem; text-align: center; }

/* RSVP button (R14) -------------------------------------------------------- */

.rsvp {
  flex: none;
  width: 4.55rem;
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}
.rsvp-none  { background: var(--rsvp-none); color: #fff; }
.rsvp-yes   { background: var(--rsvp-yes); color: var(--text); }
.rsvp-no    { background: var(--rsvp-no); color: #fff; }
.rsvp-maybe { background: var(--rsvp-maybe); color: var(--text); }
.rsvp[aria-busy="true"] { opacity: 0.75; }

/* Bottom bar: My events… and + ---------------------------------------------- */

.bottom-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 30rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(255, 255, 255, 0), #fff 30%);
}

.fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gc-green-dark);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.fab:hover { background: var(--gc-green-hover); color: #fff; }

/* Pop-ups (<dialog>) -------------------------------------------------------- */

dialog {
  border: 0;
  padding: 0;
  color: var(--text);
}
dialog::backdrop { background: rgba(31, 41, 51, 0.45); }

.sheet {
  width: min(28rem, calc(100vw - 2rem));
  max-height: 80vh;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 4px solid var(--gc-green);
  border-radius: 0.5rem;
  background: #fff;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sheet-head h2 { margin: 0; }
.close-x { font-size: 2rem; line-height: 1; }

.my-events { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.my-events li + li { border-top: 1px solid var(--border); }
.my-events a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 0.75rem;
  padding: 0.65rem 0;
  color: var(--text);
  text-decoration: none;
}
.my-events .event-title { grid-column: 1; }
.my-events .event-when { grid-column: 1; }
.my-events .tag { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.my-events a:hover .event-title { color: var(--gc-green-dark); text-decoration: underline; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
}
.tag-draft { background: var(--rsvp-maybe); color: var(--text); }
.tag-published { background: var(--gc-green-light); color: var(--gc-green-dark); }

/* Drop-down menu (SPEC 4.5): slides over the page from the left -------------- */

.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  margin: 0;
  width: min(22rem, 85vw);
  max-height: none;
  height: 100%;
  padding: 1rem 1.25rem;
  background: #fff;
  border-right: 4px solid var(--gc-green);
}
.drawer[open] { animation: slide-in 0.18s ease-out; }
@keyframes slide-in { from { transform: translateX(-100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .drawer[open] { animation: none; } }

.menu-list { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.menu-list li { display: flex; align-items: center; justify-content: space-between; }
.menu-item {
  display: block;
  padding: 0.35rem 0;
  border: 0;
  background: none;
  font-family: var(--font-head);
  font-size: 2.25rem;
  letter-spacing: 0.03em;
  line-height: 1.15;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
a.menu-item:hover, button.menu-item:hover { color: var(--gc-green-dark); }
.menu-item.is-disabled { color: #a9b1ad; cursor: default; }
.initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border: 1.5px solid var(--text);
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 600;
}

/* Toast ------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 6rem;
  transform: translateX(-50%);
  max-width: min(26rem, calc(100vw - 2rem));
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: #1f2933;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

/* Event detail (SPEC 4.3) -------------------------------------------------- */

.detail-header { justify-content: space-between; align-items: flex-start; }
.detail-header .screen-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.close-x { flex: none; font-size: 2.2rem; line-height: 1; text-decoration: none; }

.detail-top { display: flex; gap: 0.9rem; align-items: flex-start; margin-top: 0.75rem; }
.detail-photo {
  flex: none;
  width: 110px;
  height: 110px;
  border-radius: 4px;
  object-fit: cover;
}
.detail-photo.thumb-placeholder { display: block; background: var(--gc-green-light); border: 2px solid var(--gc-green); }
.detail-facts p { margin: 0; }
.detail-when { font-weight: 700; font-size: 1.1rem; }
.detail-where { font-weight: 700; font-size: 1.05rem; margin-top: 0.25rem !important; overflow-wrap: anywhere; }

.description { margin-top: 1rem; overflow-wrap: anywhere; }
.description p { margin: 0 0 0.75rem; }

.detail-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.going-text { font-family: var(--font-head); font-size: 1.6rem; letter-spacing: 0.03em; }
.detail-actions .rsvp { width: 7rem; }
.cal-btn { margin-left: auto; width: 52px; height: 52px; }

.detail-owner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}
.organiser { margin: 0; }
.detail-owner-row .btn { margin-left: auto; }
.rsvp-counts { margin: 0.5rem 0 0; font-weight: 700; color: var(--gc-green-dark); }

.map-wrap {
  position: relative;
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.map { height: 320px; background: #e8ece9; }
.map-link { position: absolute; inset: 0 0 18px 0; z-index: 500; }   /* leaves the © credit clickable */
.map-link:focus-visible { outline-offset: -4px; }

.sheet-body { margin-top: 1rem; }

/* Edit event (SPEC 4.4) ----------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.status-bar {
  margin: 0.75rem 0 0.6rem;
  padding: 0.35rem;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 4px;
}
.status-draft { background: var(--rsvp-maybe); color: var(--text); }
.status-published { background: var(--gc-green-light); color: var(--gc-green-dark); }

.edit-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.9rem; }
.edit-buttons .btn { flex: 1 1 auto; font-size: 1rem; padding: 0.5rem 0.75rem; }

.title-input {
  font-family: var(--font-body);
  font-size: 1.12rem !important;
  font-weight: 700;
}

.when-row { display: flex; gap: 0.75rem; margin-top: 0.75rem; align-items: stretch; }
.photo-tile {
  flex: none;
  width: 120px;
  height: 120px;
  padding: 0;
  border: 1.5px solid var(--text);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-plus {
  width: 56px; height: 56px;
  border: 2px solid var(--text);
  border-radius: 50%;
  font-size: 2rem; line-height: 52px; text-align: center;
}
.when-fields {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.6rem;
  align-items: center;
}
.when-fields label { font-weight: 400; }
.when-fields input { min-height: 38px; padding: 0.3rem 0.5rem; font-size: 1.05rem; }
.to-wrap { display: flex; align-items: center; gap: 0.4rem; }
.to-wrap input { width: auto; }
.next-day { color: var(--gc-muted); font-size: 0.9rem; white-space: nowrap; }

.address-row { display: flex; gap: 0.5rem; align-items: center; margin-top: 1rem; }
.address-row .pin { flex: none; }
.address-row textarea { flex: 1; min-height: 52px; resize: vertical; font-size: 0.77rem; }
.address-row .btn { flex: none; }
.latlon { margin: 0.3rem 0 0 2.3rem; font-size: 0.9rem; }

.desc-label { display: block; margin-top: 1rem; font-weight: 400; font-size: 1.1rem; }
textarea#description { min-height: 12rem; resize: vertical; font-size: 0.99rem; }

.field-error { margin: 0.25rem 0 0; color: #8f1e18; font-weight: 600; font-size: 0.95rem; }
[aria-invalid="true"] { border-color: var(--danger) !important; border-width: 2px !important; }

/* Edit pop-ups */
.sheet-wide { width: min(36rem, calc(100vw - 1.5rem)); max-height: 92vh; overflow: auto; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.9rem; }
.confirm-text { font-size: 1.1rem; font-weight: 600; margin: 0.25rem 0 0; }

.map-search { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.map-search input { width: 100%; min-height: 48px; font-size: 0.99rem; }
.map-status { min-height: 1.2em; margin: 0.35rem 0; }
.map-pick { position: relative; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.map-pick .map { height: min(55vh, 420px); }
.center-pin {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -100%);   /* the pin's tip marks the centre */
  z-index: 500;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}

.upload-btn { margin-top: 0.75rem; cursor: pointer; }
.photo-grid {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.5rem;
}
.photo-choice { padding: 0; border: 2px solid transparent; border-radius: 4px; background: none; cursor: pointer; width: 100%; }
.photo-choice:hover { border-color: var(--gc-green-dark); }
.photo-choice img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 2px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--danger); text-decoration: underline; font: inherit; cursor: pointer; }

.crop-area { margin-top: 0.75rem; max-height: 60vh; background: #222; }
.crop-area img { display: block; max-width: 100%; }

.copy-list { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.copy-list li + li { border-top: 1px solid var(--border); }
.copy-choice {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%;
  padding: 0.5rem 0;
  border: 0; background: none;
  font: inherit; color: var(--text); text-align: left;
  cursor: pointer;
}
.copy-choice:hover .event-title { color: var(--gc-green-dark); text-decoration: underline; }
.copy-choice .thumb { width: 48px; height: 48px; }
