/* MyPar shared application shell — intentionally loaded after each page's local styles. */
:root {
  --navy: #071d36;
  --navy-2: #0d2b4c;
  --mustard: #d6a21e;
  --mustard-light: #f4cf65;
  --cream: #f7f3e8;
  --card: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --border: #d8d3c4;
  --line: #d8d3c4;
  --danger: #b42318;
  --success: #137333;
  --shadow: 0 8px 24px rgba(7, 29, 54, 0.09);
}

html { background: var(--cream); }
body {
  margin: 0;
  background: var(--cream);
  color: var(--navy);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Shared header + navigation ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  padding: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  border-bottom: 4px solid var(--mustard);
  box-shadow: 0 3px 14px rgba(7, 29, 54, 0.18);
}

.app-header .brand {
  width: min(100%, 1400px);
  min-height: 82px;
  margin: 0 auto;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  align-items: center;
  gap: 24px;
  box-sizing: border-box;
}

.brand-home {
  display: inline-block;
  color: inherit;
  text-decoration: none;
  min-width: max-content;
}

.brand-title {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -1.25px;
}

.brand-title span { color: var(--mustard); }
.brand-subtitle {
  margin: 5px 0 0;
  color: #dce6f1;
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: .01em;
}

.primary-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  color: #dce6f1;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .01em;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}

.nav-link:hover {
  background: rgba(255,255,255,.10);
  color: #fff;
}
.nav-link.is-active,
.nav-link[aria-current="page"] {
  color: var(--navy);
  background: var(--mustard);
}

.auth-status {
  min-width: 0;
  padding: 0 0 0 18px;
  border: 0;
  border-left: 1px solid rgba(255,255,255,.17);
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  text-align: right;
}

.account-copy {
  min-width: 0;
  max-width: 220px;
}
.account-label {
  display: block;
  margin-bottom: 2px;
  color: #aebed0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
#authMessage {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.auth-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}
.header-action,
.header-logout {
  min-height: 34px;
  margin: 0;
  padding: 7px 10px;
  border-radius: 9px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.header-action {
  color: #fff;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.18);
}
.header-logout {
  width: auto;
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255,255,255,.30);
}
.header-action:hover,
.header-logout:hover { background: rgba(255,255,255,.15); }

.mobile-nav { display: none; }

body:not(.is-logged-in) .primary-nav,
body:not(.is-logged-in) .app-header .auth-status,
body:not(.is-logged-in) .mobile-nav { display: none !important; }
body:not(.is-logged-in) .app-header .brand {
  grid-template-columns: 1fr;
  justify-items: center;
  min-height: 92px;
}
body:not(.is-logged-in) .brand-home { text-align: center; }

/* ---------- Shared page rhythm ---------- */
.page {
  width: min(100%, 1400px);
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 56px;
  box-sizing: border-box;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.panel h2,
.panel h3 { color: var(--navy); }

.app-page-heading,
.top-actions.app-page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 18px;
}
.page-heading-copy { min-width: 0; }
.page-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: #8a6912;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .10em;
  text-transform: uppercase;
}
.app-page-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: 26px;
  letter-spacing: -.5px;
}
.app-page-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}
.page-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
body:not(.is-logged-in) .app-page-heading { display: none !important; }

/* ---------- Shared controls ---------- */
.form-field,
.filter-field { min-width: 0; }
.form-label,
.filter-label {
  display: block;
  margin: 0 0 7px;
  color: #4a5567;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.form-field select,
.form-field input,
.filter-field select,
.filter-field input,
.auth-row input,
.selectors select {
  min-height: 46px;
  border-radius: 10px;
  border-color: var(--border);
  font: inherit;
}
select:focus,
input:focus {
  outline: 3px solid rgba(214,162,30,.22);
  border-color: var(--mustard) !important;
}

.button-link,
.page-heading-actions button,
.round-actions > button,
.round-actions > .button-link,
.filter-buttons button,
.auth-row > button {
  border-radius: 10px;
  font-family: inherit;
  font-weight: 800;
}
.button-secondary { background: var(--mustard); color: var(--navy); }
.button-danger {
  color: var(--danger);
  background: #fff;
  border: 1px solid #e7b7b2;
}

/* ---------- Consistent login ---------- */
#authPanel {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  padding: 22px;
}
#authPanel h2 { font-size: 21px; }
.form-message { font-weight: 600; }
.google-login-button {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #1f2937;
  background: #fff;
  border: 1px solid #c9cdd3;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.google-login-button:hover { background: #f8fafc; }
.google-mark {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #4285f4;
  font-family: Arial, sans-serif;
  font-size: 16px;
  font-weight: 900;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--border);
  flex: 1;
}
.auth-help a {
  color: var(--navy);
  font-weight: 800;
  text-decoration-color: var(--mustard);
  text-underline-offset: 3px;
}

/* ---------- Play ---------- */
.page-play .selectors.selection-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 20px;
  padding: 18px;
}
.page-play .selection-summary { border-radius: 14px; }
.page-play .score-card,
.page-rounds .summary-card,
.page-analysis .summary-card {
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.page-play #roundPanel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.page-play #roundPanel h2 { margin-bottom: 5px; }
.page-play #roundPanel p { margin: 0; color: var(--muted); }
.page-play .round-actions { margin: 0; flex: 0 0 auto; }

/* ---------- Rounds + Analysis summary system ---------- */
.page-rounds .summary-card,
.page-analysis .summary-card {
  min-height: 112px;
  padding: 16px;
  color: #fff;
  background: var(--navy);
  border: 0;
  border-bottom: 5px solid var(--mustard);
}
.page-rounds .summary-card.mustard,
.page-analysis .summary-card.mustard {
  color: var(--navy);
  background: var(--mustard);
  border-bottom-color: var(--navy);
}
.page-rounds .summary-card .summary-label,
.page-rounds .summary-card .summary-note,
.page-analysis .summary-card .summary-label,
.page-analysis .summary-card .summary-note { color: inherit; }
.page-rounds .summary-card .summary-note,
.page-analysis .summary-card .summary-note { opacity: .78; }
.page-rounds .summary-card input { color: var(--navy); background: #fff; }

.page-analysis .selectors {
  align-items: end;
}
.page-analysis .checkbox-filter {
  min-height: 46px;
  display: flex;
  align-items: center;
}
.page-analysis .checkbox-filter label {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}
.page-analysis .checkbox-filter input {
  width: 20px;
  min-height: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--mustard);
}
.page-analysis .insight { border-radius: 12px; }
.page-analysis .pill { border-color: var(--border); }

/* ---------- Reset password ---------- */
.auth-page .app-header { position: relative; }
.auth-page .app-header .brand {
  grid-template-columns: 1fr auto;
  width: min(100%, 720px);
}
.auth-page .auth-back {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  color: #fff;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.08);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}
.auth-page .page { min-height: calc(100vh - 86px); }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .app-header .brand {
    grid-template-columns: auto 1fr auto;
    gap: 12px;
  }
  .primary-nav { gap: 2px; }
  .nav-link { padding: 0 11px; }
  .account-copy { display: none; }
  .auth-status { padding-left: 10px; }
}

@media (max-width: 760px) {
  /* Mobile keeps the primary destinations inside the navy header. This frees
     the bottom edge for the live score strip on Play and maximises usable
     vertical space while scoring. */
  body.page-play.is-logged-in {
    padding-bottom: calc(126px + env(safe-area-inset-bottom, 0px));
  }
  body.page-play.is-logged-in .page {
    padding-bottom: calc(34px + env(safe-area-inset-bottom, 0px));
  }
  body.page-play.is-logged-in .scorecards {
    bottom: 0;
    z-index: 70;
  }

  .app-header .brand {
    min-height: 0;
    padding: 9px 12px 8px;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand account"
      "nav nav";
    gap: 7px 10px;
  }
  .brand-home { grid-area: brand; }
  .brand-title { font-size: 29px; }
  .brand-subtitle { display: none; }

  .primary-nav {
    grid-area: nav;
    width: 100%;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding-top: 7px;
    border-top: 1px solid rgba(255,255,255,.14);
  }
  .nav-link {
    min-height: 35px;
    padding: 0 8px;
    border-radius: 9px;
    font-size: 12px;
  }

  .auth-status {
    grid-area: account;
    display: flex;
    border-left: 0;
    padding-left: 0;
  }
  .auth-actions { gap: 6px; }
  .header-action { display: none; }
  .header-logout { min-height: 34px; padding: 7px 9px; }

  .mobile-nav { display: none !important; }

  .page { padding: 18px 12px 30px; }
  .app-page-heading,
  .top-actions.app-page-heading {
    align-items: center;
    margin-bottom: 14px;
  }
  .app-page-heading h2 { font-size: 22px; }
  .app-page-heading p { font-size: 13px; }
  .page-heading-actions .button-link { display: none; }

  .page-play .selectors.selection-panel {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 15px;
  }
  .page-play #roundPanel {
    align-items: stretch;
    flex-direction: column;
  }
  .page-play .round-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .page-play .round-actions > * { width: 100%; box-sizing: border-box; }

  #authPanel { padding: 18px; }
  .auth-row { grid-template-columns: 1fr !important; }
  .auth-row > input,
  .auth-row > button { width: 100%; box-sizing: border-box; }

  .auth-page .app-header .brand {
    grid-template-columns: 1fr auto;
    justify-items: stretch;
  }
  .auth-page .brand-home { text-align: left; }
  .auth-page .auth-back { font-size: 12px; padding: 0 10px; }
}

@media (max-width: 420px) {
  .page-heading-actions button { padding-left: 10px; padding-right: 10px; }
  .page-eyebrow { display: none; }
  .app-page-heading p { max-width: 250px; }
}

/* Logged-out state is intentionally the same on every main screen. */
body:not(.is-logged-in):not(.auth-page) .page {
  max-width: 560px;
  min-height: calc(100vh - 96px);
  display: flex;
  align-items: center;
  justify-content: center;
}
body.page-analysis:not(.is-logged-in) .page > :not(#authPanel) {
  display: none !important;
}

/* Reset-password is an auth utility, so keep its explicit two-part header. */
body.auth-page .app-header .brand {
  grid-template-columns: 1fr auto;
  justify-items: stretch;
}
body.auth-page .brand-home { text-align: left; }
