/* ==========================================================================
   Custom SOGo login-page styling.

   Injected by an nginx sub_filter <link> tag; nothing under /usr/lib/GNUstep
   is modified, so SOGo package upgrades stay clean.

   LAYOUT NOTE (learned the hard way): the login page is Angular Material -
      <div id="loginContent" layout="column" layout-gt-md="row">
        <div flex-gt-md="50" class="sg-logo">   <- banner
        <div flex-gt-md="50" class="sg-login">  <- form
   .sg-logo and .sg-login are FLEX ITEMS. Do not give them `container-type`
   (that applies CSS containment) and do not use `min-height:100%` against
   the auto-height parent - either one collapses the panel. Keep overrides
   additive: colour, type and the injected brand block only.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Banner (left / top panel)
   Contrast strategy: the per-domain hash rotates HUE only - saturation and
   lightness stay pinned, so no hue can produce an illegible pairing. Text is
   either near-white on a near-black tinted ground, or near-black on a pale
   chip. Saturated colour appears only in low-alpha decoration, never under
   text.
   -------------------------------------------------------------------------- */

.sg-logo {
  --h1: 214;                                  /* fallbacks if JS hasn't run */
  --h2: 252;
  --ink:      hsl(var(--h1) 24% 96%);
  --ink-soft: hsl(var(--h1) 22% 74%);
  --panel:    hsl(var(--h1) 34% 11%);
  --panel-2:  hsl(var(--h2) 30% 16%);
  --tint:     hsl(var(--h1) 52% 74%);
  --tint-2:   hsl(var(--h2) 48% 70%);
  --chip-a:   hsl(var(--h1) 58% 82%);
  --chip-b:   hsl(var(--h2) 62% 73%);
  --chip-ink: hsl(var(--h1) 48% 13%);

  position: relative;
  overflow: hidden;

  /* flex, not grid - matches what Material already expects of this item.
     Explicit min-height in rem (NOT %) so the panel always has a box. */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 20rem;
  padding: 2.5rem 2rem;
  box-sizing: border-box;

  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--ink);

  background:
    radial-gradient(34rem 26rem at 12% -8%,
      hsl(var(--h1) 65% 52% / 0.16), transparent 62%),
    radial-gradient(28rem 22rem at 102% 108%,
      hsl(var(--h2) 60% 55% / 0.13), transparent 64%),
    linear-gradient(155deg, var(--panel-2), var(--panel) 58%);
}

/* the SOGo logo, gone */
.sg-logo img,
.sg-logo picture { display: none !important; }

/* Faint engraved rings. Origin is computed from the hue numbers, so each
   domain gets its own geometry as well as its own colour. Decorative only -
   pointer-events:none so it can never sit over the form. */
.sg-logo::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-radial-gradient(
    circle at calc(16% + var(--h1) * 0.18%) calc(115% - var(--h2) * 0.10%),
    hsl(var(--h2) 40% 82% / 0.05) 0 1px, transparent 1px 46px);
}

/* ---- the lockup (built by login.js) ---- */

.sgc-brand {
  position: relative;
  z-index: 1;                    /* above the decoration */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  max-width: 100%;
  min-width: 0;
}

/* Monogram coin: pale chip + near-black ink is the one pairing HSL cannot
   sabotage, because pale stays pale at every hue. */
.sgc-monogram {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  flex: none;
  border-radius: 1.1rem;
  background: linear-gradient(140deg, var(--chip-a), var(--chip-b));
  color: var(--chip-ink);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: inset 0 1px 0 hsl(var(--h1) 60% 93% / 0.85),
              0 12px 26px -14px hsl(var(--h1) 50% 6% / 0.9);
}

/* Fluid on viewport width (no container queries - see layout note above).
   Sized so a 22-character label still fits the half-width panel. */
.sgc-wordmark {
  max-width: 100%;
  min-width: 0;
  font-size: clamp(1.1rem, 2.1vw, 1.85rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.sgc-wordmark::after {
  content: "";
  display: block;
  margin-top: 0.65rem;
  width: 2.6rem;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(90deg, var(--tint), var(--tint-2) 70%, transparent);
}

.sgc-domain { color: var(--ink); }

.sgc-tld {
  color: var(--tint-2);
  font-weight: 500;
}

.sgc-eyebrow {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   Form panel - deliberately light touch. No layout overrides, no width
   clamps: colour and type only, so Material's own sizing keeps working.
   -------------------------------------------------------------------------- */

.sg-login {
  background: #f8fafc !important;
  color: #0f172a !important;
}

.sg-login,
.sg-login input,
.sg-login button,
.sg-login .md-button {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
}

/* "About SOGo" dialog trigger - more SOGo branding, hidden. */
#login md-button[aria-label="About"] { display: none !important; }

.sg-login input[type="text"],
.sg-login input[type="password"] { color: #0f172a !important; }

.sg-login .md-fab,
.sg-login .md-fab.md-accent.md-hue-2 {
  background-color: #0f172a !important;
  color: #fff !important;
}
.sg-login .md-fab:hover { background-color: #1e293b !important; }

/* --------------------------------------------------------------------------
   Narrow screens: Material switches #loginContent to layout="column", so the
   banner becomes a short band above the form.
   -------------------------------------------------------------------------- */

@media (max-width: 959px) {
  .sg-logo {
    min-height: 9rem;
    padding: 1.5rem;
    align-items: flex-start;
  }
  .sgc-brand {
    flex-direction: row;
    align-items: center;
    gap: 0.9rem;
  }
  .sgc-monogram {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.85rem;
    font-size: 1rem;
  }
  .sgc-wordmark { font-size: clamp(1rem, 4.5vw, 1.4rem); }
  .sgc-wordmark::after { display: none; }
  .sgc-eyebrow { display: none; }
}
