/* ============================================================
   POCKETEER MD3 — Login / Register (CORE, shared)
   Pattern A: single responsive card with Login | Register tabs.
   Tokens come from core: css/brand.css. Self-contained — no
   dependency on the app landing CSS.
   ============================================================ */

html, body { margin: 0; padding: 0; }
body { overflow-x: hidden; }

.lgn-page {
  box-sizing: border-box;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 20px;
  background: var(--bg);
  color: var(--on-surface);
  font-family: var(--font);
  position: relative;
  overflow: hidden;
}
.lgn-page::before,
.lgn-page::after {
  content: ''; position: absolute; border-radius: 50%;
  filter: blur(20px); pointer-events: none;
}
.lgn-page::before {
  top: -200px; right: -200px; width: 600px; height: 600px;
  background: radial-gradient(circle, var(--p-90), transparent 70%);
}
.lgn-page::after {
  bottom: -200px; left: -200px; width: 500px; height: 500px;
  background: radial-gradient(circle, var(--t-90), transparent 70%);
}

.lgn-wrap { position: relative; width: 100%; max-width: 460px; }

.lgn-logo {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin-bottom: 28px;
}
.lgn-logo .mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
}
.lgn-logo .name { font: 800 26px/1 var(--font); letter-spacing: -.03em; color: var(--on-surface); }
.lgn-logo .name b { color: var(--p-50); font-weight: 800; }

.lgn-card {
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-xl);
  box-shadow: var(--el-3);
  overflow: hidden;
}

/* segmented tabs */
.lgn-tabs-wrap { padding: 8px; background: var(--surface-1); }
.lgn-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px; background: var(--surface-2); border-radius: 14px;
}
.lgn-tab {
  border: 0; padding: 12px 16px; border-radius: 10px;
  font: var(--label-l); cursor: pointer; text-align: center;
  background: transparent; color: var(--on-surface-muted);
  transition: all .2s var(--ease-emph);
}
.lgn-tab:hover { color: var(--on-surface); }
.lgn-card[data-tab='login'] .lgn-tab-login,
.lgn-card[data-tab='register'] .lgn-tab-register {
  background: var(--surface); color: var(--p-40); box-shadow: var(--el-1);
}

/* panes */
.lgn-pane { display: none; }
.lgn-card[data-tab='login'] .lgn-pane-login { display: block; }
.lgn-card[data-tab='register'] .lgn-pane-register { display: block; }

.lgn-body { padding: 20px 32px 28px; }
.lgn-h2 { font: var(--headline-m); margin: 0 0 20px !important; }

/* login method toggle (Password / Email code) */
.lgn-method { display: flex; gap: 8px; margin-bottom: 20px; }
.lgn-method a {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 10px; border-radius: 10px;
  border: 1px solid var(--outline-variant); background: transparent;
  color: var(--on-surface-muted); font: var(--label-l); font-size: 13px;
  text-decoration: none; cursor: pointer; transition: all .2s var(--ease-emph);
}
.lgn-method a:hover { border-color: var(--p-40); }
.lgn-method a.active { background: var(--p-95); color: var(--p-30); border-color: var(--p-80); }

/* fields */
.lgn-fields { display: grid; gap: 14px; }
.lgn-field { display: flex; flex-direction: column; }
.lgn-field > label,
.lgn-field .ui-outputlabel {
  font: var(--label-l); font-size: 12px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--on-surface-muted); margin-bottom: 6px;
}
.lgn-card .lgn-field input,
.lgn-card .lgn-field .ui-inputfield,
.lgn-card .lgn-field .ui-inputtext,
.lgn-card .lgn-field .ui-password,
.lgn-card .lgn-field .ui-password-input,
.lgn-card .lgn-field .ui-inputmask {
  width: 100%; font: var(--body-l);
  padding: 14px 16px; margin: 0;
  background: var(--surface-1);
  border: 1.5px solid var(--outline);
  border-radius: 12px; color: var(--on-surface);
  outline: 0; box-shadow: none;
  transition: border .2s, background .2s;
}
.lgn-card .lgn-field input:focus,
.lgn-card .lgn-field .ui-inputfield:focus,
.lgn-card .lgn-field .ui-password-input:focus,
.lgn-card .lgn-field .ui-inputmask:focus {
  border-color: var(--p-40); background: var(--surface);
  box-shadow: 0 0 0 3px var(--p-90);
}
/* PF may wrap p:password in a span.ui-password with an inner
   input.ui-password-input — make that wrapper full-width. When
   p:password renders the input directly (class ui-password) the
   styled rule above already covers it. */
.lgn-card .lgn-field span.ui-password { display: block; width: 100%; padding: 0; border: 0; background: transparent; }
.lgn-field .ui-message,
.lgn-field .ui-message-error {
  margin-top: 6px; font: var(--body-s); color: var(--e-40);
  background: transparent; border: 0; padding: 0;
}
.lgn-field .ui-message .ui-message-error-icon { display: none; }

.lgn-forgot { text-align: right; }
.lgn-forgot a {
  font: var(--body-s); color: var(--p-40); font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.lgn-hint {
  font: var(--body-s); color: var(--on-surface-muted);
  display: flex; align-items: flex-start; gap: 8px; padding: 4px 2px;
}
/* OWN the leading icon (the theme sizes .pi at 1rem): render it as a fixed box
   the height of the first text line (body-s = 13px*1.5 = 19.5px) and centre the
   glyph, so it sits on line 1 instead of riding above it. The .lgn-card prefix
   lifts it above the theme's icon rules. */
.lgn-card .lgn-hint > .pi {
  flex: 0 0 auto;
  display: inline-flex !important; align-items: center; justify-content: center;
  width: 16px; height: 19.5px;
  font-size: 14px !important; line-height: 1 !important;
  margin-top: 5px;
}
/* hint rows use an inline <svg> (not .pi) — nudge it onto the first text line */
.lgn-card .lgn-hint > svg { margin-top: 7px; }

/* primary / submit buttons — let the material-3-pocketeer theme give the
   MD3 pill look; we only size them. */
.lgn-card .lgn-submit .ui-button {
  width: 100%; justify-content: center; margin: 8px 0 0; border-radius: 12px !important;
}
.lgn-card .lgn-submit:not(.tonal) .ui-button { box-shadow: var(--el-1); }
.lgn-card .lgn-submit:not(.tonal) .ui-button:hover { box-shadow: var(--el-2); }
.lgn-card .lgn-submit.tonal .ui-button {
  background: var(--p-90); color: var(--p-20); box-shadow: none;
}

/* terms row */
.lgn-terms { margin-top: 4px; }
.lgn-terms .lgn-hint a { color: var(--p-40); font-weight: 700; cursor: pointer; }
.lgn-terms-check { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; }
/* checkbox: fixed size, no theme margin (we own the gap) */
.lgn-terms-check .ui-chkbox { flex: 0 0 auto; margin: 0; }
/* OWN the box + checkmark instead of inheriting the PrimeFaces theme. The
   .lgn-card prefix lifts these above the theme's .ui-chkbox .ui-chkbox-box rules. */
.lgn-card .lgn-terms-check .ui-chkbox-box {
  box-sizing: border-box;
  width: 18px !important; min-width: 18px; height: 18px !important; margin-top: 1px;
  border: 2px solid var(--outline) !important; border-radius: 6px !important;
  background: var(--surface-1) !important; position: relative;
  transition: background .15s, border-color .15s;
}
.lgn-card .lgn-terms-check .ui-chkbox-box.ui-state-hover { border-color: var(--p-40) !important; }
.lgn-card .lgn-terms-check .ui-chkbox-box.ui-state-disabled { opacity: .45; }
/* hide the theme's primeicon glyph; draw our own white SVG check when active */
.lgn-card .lgn-terms-check .ui-chkbox-icon { display: none !important; }
.lgn-card .lgn-terms-check .ui-chkbox-box.ui-state-active {
  border-color: var(--p-40) !important;
  background: var(--p-40) url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23fff'%20stroke-width='3'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M5%2012l5%205L20%207'/%3E%3C/svg%3E") center / 12px 12px no-repeat !important;
}
/* label takes the rest of the row and wraps cleanly beside the box */
.lgn-terms-check .ui-outputlabel { flex: 1; margin: 0; text-transform: none; letter-spacing: 0; font: var(--body-s); line-height: 1.45; color: var(--on-surface); }

/* footer line — the "no dead end" cross-link */
.lgn-foot {
  border-top: 1px solid var(--outline-variant);
  padding: 16px 32px; text-align: center;
  font: var(--body-s); color: var(--on-surface-muted);
  background: var(--surface-1);
}
.lgn-foot a { color: var(--p-40); font-weight: 700; cursor: pointer; text-decoration: none; }
.lgn-foot .lgn-foot-register { display: none; }
.lgn-card[data-tab='register'] .lgn-foot .lgn-foot-login { display: none; }
.lgn-card[data-tab='register'] .lgn-foot .lgn-foot-register { display: inline; }

/* No underline on any login button/link in any state (overrides the
   PrimeFaces theme's a:hover underline). */
.lgn-page a,
.lgn-page a:hover,
.lgn-page a:focus,
.lgn-page .ui-commandlink,
.lgn-page .ui-commandlink:hover,
.lgn-page .ui-commandlink:focus,
.lgn-page .ui-button,
.lgn-page .ui-button:hover,
.lgn-page .lgn-tab,
.lgn-page .lgn-tab:hover { text-decoration: none; }

/* ===== terms-of-use dialog — MD3 (desktop = centered modal) ===== */
.terms-of-use-dialog.ui-dialog {
  border: 0; border-radius: var(--r-xl); padding: 0;
  box-shadow: var(--el-3); overflow: hidden;
  background: var(--surface);
  /* PF sets an explicit inline height on the dialog/content (auto-resize) —
     force auto so the modal sizes to its content, not the viewport. */
  height: auto !important;
  max-height: 70vh;
}
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar {
  position: relative;
  background: var(--surface-1); border: 0;
  border-bottom: 1px solid var(--outline-variant);
  padding: 18px 24px; border-radius: 0;
}
.terms-of-use-dialog.ui-dialog .ui-dialog-title {
  font: var(--headline-s); color: var(--on-surface);
}
/* hide the jQuery-UI maximize icon entirely; redraw close as a clean X */
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar-maximize { display: none; }
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar-icon {
  position: relative; width: 34px; height: 34px;
  border-radius: 999px; color: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar-icon .ui-icon {
  display: none;
}
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar-close::before,
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar-close::after {
  content: ''; position: absolute;
  width: 16px; height: 2px; border-radius: 2px;
  background: var(--on-surface-muted);
}
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar-close::before { transform: rotate(45deg); }
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar-close::after { transform: rotate(-45deg); }
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar-close:hover {
  background: var(--surface-2);
}
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar-close:hover::before,
.terms-of-use-dialog.ui-dialog .ui-dialog-titlebar-close:hover::after {
  background: var(--on-surface);
}
.terms-of-use-dialog.ui-dialog .ui-dialog-content {
  background: var(--surface); padding: 16px 20px 20px;
  height: auto !important; max-height: 58vh; overflow: auto;
}
/* the dialog content is wrapped in nested ui-outputpanel / .p-3 —
   strip their padding/margin so there is no superfluous frame */
.terms-of-use-dialog .ui-dialog-content > .ui-outputpanel,
.terms-of-use-dialog .ui-dialog-content .ui-outputpanel,
.terms-of-use-dialog .ui-dialog-content .p-3 { padding: 0; margin: 0; }
/* dialog is not resizable — kill any stray handles */
.terms-of-use-dialog .ui-resizable-handle { display: none; }
.terms-of-use-dialog .ui-dialog-content h2 { font: var(--headline-s); color: var(--on-surface); margin: 0 0 8px; }

.terms-of-use-dialog .tos-accordion-panel,
.terms-of-use-dialog .tos-accordion-panel.ui-accordion { border: 0; background: transparent; }
.terms-of-use-dialog .tos-accordion-panel .ui-accordion-header {
  margin-top: 10px; border: 1px solid var(--outline-variant);
  border-radius: var(--r-lg); background: var(--surface-1);
}
.terms-of-use-dialog .tos-accordion-panel .ui-accordion-header > a {
  padding: 16px 18px; font: var(--title-m); color: var(--on-surface); text-decoration: none;
}
.terms-of-use-dialog .tos-accordion-panel .ui-accordion-header.ui-state-active {
  background: var(--p-95); border-color: var(--outline-variant); border-bottom-color: transparent;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
/* hover feedback (login-md3 had none -> base theme made it transparent/near-invisible) */
.terms-of-use-dialog .tos-accordion-panel .ui-accordion-header:not(.ui-state-active):hover {
  border-color: var(--p-40); background: var(--surface-2);
}
.terms-of-use-dialog .tos-accordion-panel .ui-accordion-header.ui-state-active:hover {
  background: var(--p-90); border-color: var(--outline-variant); border-bottom-color: transparent;
}
.terms-of-use-dialog .tos-accordion-panel .ui-accordion-content {
  border: 1px solid var(--outline-variant); border-top: 0;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  background: var(--surface); padding: 18px 20px;
  color: var(--on-surface-muted); font: var(--body-m); line-height: 1.7;
}
/* The PF theme :first-child / -last rules force the small 8px ($borderRadius) corner, which made
   the first header's top "shrink" once the active tab was collapsed. Pin both ends to --r-lg so
   every closed header is a uniform pill (last header skips it while active = content attached). */
.terms-of-use-dialog .tos-accordion-panel .ui-accordion-header:first-child {
  border-top: 1px solid var(--outline-variant);
  border-top-left-radius: var(--r-lg);
  border-top-right-radius: var(--r-lg);
}
.terms-of-use-dialog .tos-accordion-panel .ui-accordion-header.ui-accordion-header-last:not(.ui-state-active) {
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
}

/* ============================================================
   MOBILE (<= 600px) — per design, login is a full-screen stacked
   layout (no card chrome / blobs) and dialogs become bottom sheets.
   ============================================================ */
@media (max-width: 600px) {
  /* login: full-bleed stacked, no elevated card */
  .lgn-page { padding: 24px 16px; align-items: start; }
  .lgn-page::before, .lgn-page::after { display: none; }
  .lgn-wrap { max-width: none; }
  .lgn-logo { margin: 8px 0 24px; }
  .lgn-logo .name { font-size: 20px; }
  .lgn-card {
    border: 0; box-shadow: none; border-radius: 0; background: transparent;
  }
  .lgn-tabs-wrap { background: transparent; padding: 0 0 8px; }
  .lgn-body { padding: 20px 2px 8px; }
  .lgn-foot {
    background: transparent; border-top: 1px solid var(--outline-variant);
    padding: 16px 2px 0; margin-top: 8px;
  }

  /* terms-of-use dialog: bottom sheet (slide up from bottom) */
  .terms-of-use-dialog.ui-dialog {
    position: fixed !important;
    left: 0 !important; right: 0 !important; bottom: 0 !important;
    top: auto !important;
    width: 100% !important; max-width: 100% !important;
    max-height: 88vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: lgn-sheet-up .5s var(--ease-emph) both;
  }
  .terms-of-use-dialog.ui-dialog .ui-dialog-content { max-height: calc(88vh - 60px); }
  @keyframes lgn-sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .terms-of-use-dialog.ui-dialog .ui-dialog-titlebar {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding-top: 28px;
  }
  .terms-of-use-dialog.ui-dialog .ui-dialog-titlebar::before {
    content: ''; position: absolute; top: 10px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 999px;
    background: var(--outline);
  }
  .terms-of-use-dialog.ui-dialog .ui-dialog-content {
    max-height: calc(88vh - 64px); overflow: auto;
  }
}
