/* ============================================
   EUDHOS IDENTITY PAGES - Authentication Styling
   ============================================
   Matches the Eudhos design system for consistent UX
   across login, register, password reset, and account management
   ============================================ */

/* ============================================
   HEADER WITH CENTERED LOGO
   ============================================ */
.identity-header {
    background: #0a0a0a;
    border-bottom: 1px solid #ffffff10;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.identity-home-link {
    position: absolute;
    left: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #ffffff08;
    border: 1px solid #ffffff15;
    color: #888888;
    text-decoration: none;
    transition: all 0.2s ease;
}

.identity-home-link:hover {
    background: #5DA8CB20;
    border-color: #5DA8CB50;
    color: #7DC8EB;
}

.identity-home-link svg {
    width: 16px;
    height: 16px;
}

.identity-logo-link {
    display: block;
    text-decoration: none;
}

.identity-header-logo {
    /* Was 180px, which turned the header into a banner. Icon-sized now. */
    max-width: 40px;
    height: auto;
    display: block;
}

/* User status (right side of header) */
.identity-user-status {
    position: absolute;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.identity-user-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: #ffffff08;
    border: 1px solid #ffffff15;
    color: #aaaaaa;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    max-width: 200px;
}

.identity-user-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.identity-user-link:hover {
    background: #5DA8CB20;
    border-color: #5DA8CB50;
    color: #7DC8EB;
    text-decoration: none;
}

.identity-logout-form {
    margin: 0;
    padding: 0;
}

.identity-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    background: #ffffff08;
    border: 1px solid #ffffff15;
    color: #888888;
    cursor: pointer;
    transition: all 0.2s ease;
}

.identity-logout-btn:hover {
    background: #DCA26E20;
    border-color: #DCA26E50;
    color: #DCA26E;
}

.identity-login-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: #5DA8CB20;
    border: 1px solid #5DA8CB50;
    color: #7DC8EB;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.identity-login-link:hover {
    background: #71E1D420;
    border-color: #71E1D450;
    color: #71E1D4;
    text-decoration: none;
}

/* ============================================
   LOGO STYLING (in card)
   ============================================ */
.login-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 1rem;
}

/* ============================================
   PAGE LAYOUT
   ============================================ */
.identity-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.identity-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    min-height: calc(100vh - 100px);
}

.identity-main {
    width: 100%;
    max-width: 480px;
}

/* The CAPTCHA game is the whole point of this page, not a small widget in a
   corner — give it the room to read as full-page, still centred by
   .identity-container's flex centring. */
.identity-main:has(> .identity-plain) {
    max-width: min(92vw, 900px);
}

/* ============================================
   AUTH CARD CONTAINER
   ============================================ */
.identity-main > .identity-plain {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.identity-main > div,
.identity-main > section,
.identity-main > form {
    background: #1a1a1a;
    border: 1px solid #ffffff15;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.identity-main > .row {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
}

.identity-main > .row > div {
    background: #1a1a1a;
    border: 1px solid #ffffff15;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 100%;
    flex: none;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
.identity-main h1,
.identity-main h2,
.identity-main h3,
.identity-main h4 {
    color: #eeeeee;
    text-align: center;
    margin-bottom: 1.5rem;
}

.identity-main h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #7DC8EB;
}

.identity-main h2 {
    font-size: 1rem;
    font-weight: 400;
    color: #888888;
    margin-bottom: 2rem;
}

.identity-main h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.identity-main h4 {
    font-size: 1rem;
    font-weight: 400;
    color: #aaaaaa;
    margin-bottom: 1.5rem;
}

.identity-main p {
    color: #aaaaaa;
    text-align: center;
    line-height: 1.6;
}

.identity-main hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, #ffffff20, transparent);
    margin: 1.5rem 0;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.identity-main .form-floating {
    margin-bottom: 1.25rem;
    position: relative;
}

.identity-main .form-floating > .form-control {
    background: #22222280 !important;
    border: 1px solid #ffffff15;
    border-radius: 10px;
    color: #eeeeee !important;
    font-size: 1rem;
    padding: 1.5rem 1rem 0.75rem;
    height: auto;
    min-height: 3.5rem;
    transition: all 0.2s ease;
}

.identity-main .form-floating > .form-control:hover {
    background: #252525 !important;
    border-color: #ffffff25;
}

.identity-main .form-floating > .form-control:focus {
    background: #1a1a1a !important;
    border-color: #5DA8CB60;
    box-shadow: 0 0 0 3px #5DA8CB20;
    outline: none;
}

.identity-main .form-floating > .form-control::placeholder {
    color: transparent;
}

.identity-main .form-floating > label {
    color: #777777 !important;
    font-size: 0.85rem;
    padding: 1rem;
    transition: all 0.2s ease;
}

.identity-main .form-floating > .form-control:focus ~ label,
.identity-main .form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: #5DA8CB !important;
    font-size: 0.75rem;
    transform: scale(0.85) translateY(-0.75rem) translateX(0.15rem);
}

/* Checkbox styling */
.identity-main .checkbox,
.identity-main .form-check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: #ffffff05;
    border-radius: 8px;
}

.identity-main .checkbox label,
.identity-main .form-check-label {
    color: #bbbbbb;
    font-size: 0.9rem;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: none;
}

.identity-main .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    background: #222222;
    border: 1px solid #ffffff30;
    border-radius: 4px;
    cursor: pointer;
    margin: 0;
}

.identity-main .form-check-input:checked {
    background-color: #5DA8CB;
    border-color: #5DA8CB;
}

.identity-main .form-check-input:focus {
    box-shadow: 0 0 0 2px #5DA8CB40;
}

/* ============================================
   BUTTONS
   ============================================ */
.identity-main .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    font-family: 'Saira', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1px solid transparent;
}

.identity-main .btn-primary {
    background: linear-gradient(135deg, #5DA8CB30 0%, #5DA8CB20 100%);
    border: 1px solid #5DA8CB50;
    color: #7DC8EB !important;
}

.identity-main .btn-primary:hover {
    background: linear-gradient(135deg, #71E1D430 0%, #71E1D420 100%);
    border-color: #71E1D460;
    color: #71E1D4 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(93, 168, 203, 0.2);
}

.identity-main .btn-primary:active {
    transform: translateY(0);
}

.identity-main .btn-secondary {
    background: #ffffff10;
    border: 1px solid #ffffff25;
    color: #bbbbbb !important;
}

.identity-main .btn-secondary:hover {
    background: #ffffff18;
    border-color: #ffffff35;
    color: #eeeeee !important;
}

.identity-main .btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
    min-height: 3.5rem;
    margin-top: 1.5rem;
}

.identity-main .btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* ============================================
   VALIDATION & ALERTS
   ============================================ */
.identity-main .text-danger {
    color: #DCA26E !important;
    font-size: 0.8rem;
    margin-top: 0.35rem;
    display: block;
}

.identity-main .validation-summary-errors ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    background: #DCA26E15;
    border: 1px solid #DCA26E40;
    border-radius: 8px;
    padding: 1rem;
}

.identity-main .validation-summary-errors li {
    color: #DCA26E;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.identity-main .validation-summary-errors li:last-child {
    margin-bottom: 0;
}

.identity-main .alert {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.identity-main .alert-success {
    background: #71E1D415;
    border: 1px solid #71E1D440;
    color: #71E1D4;
}

.identity-main .alert-danger {
    background: #DCA26E15;
    border: 1px solid #DCA26E40;
    color: #DCA26E;
}

.identity-main .alert-info {
    background: #5DA8CB15;
    border: 1px solid #5DA8CB40;
    color: #7DC8EB;
}

.identity-main .alert-warning {
    background: #E2E49015;
    border: 1px solid #E2E49040;
    color: #E2E490;
}

.identity-main .alert .btn-close {
    filter: invert(1);
    opacity: 0.5;
    padding: 0.5rem;
}

.identity-main .alert .btn-close:hover {
    opacity: 1;
}

/* ============================================
   LINKS
   ============================================ */
.identity-main a {
    color: #71E1D4;
    text-decoration: none;
    transition: color 0.2s ease;
    font-weight: 500;
}

.identity-main a:hover {
    color: #7DC8EB;
    text-decoration: underline;
}

.identity-main .text-center {
    text-align: center;
}

.identity-main .text-center p {
    margin-bottom: 0.75rem;
}

.identity-main .pt-3 {
    padding-top: 1.5rem !important;
    margin-top: 0.5rem;
    border-top: 1px solid #ffffff10;
}

/* ============================================
   MANAGE ACCOUNT PAGES
   ============================================ */
.identity-main .nav-pills {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0;
    list-style: none;
    margin-bottom: 2rem;
}

.identity-main .nav-pills .nav-item {
    margin: 0;
}

.identity-main .nav-pills .nav-link {
    display: block;
    padding: 0.85rem 1.25rem;
    background: #ffffff08;
    border: 1px solid #ffffff10;
    border-radius: 8px;
    color: #aaaaaa;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.identity-main .nav-pills .nav-link:hover {
    background: #ffffff12;
    border-color: #ffffff20;
    color: #eeeeee;
}

.identity-main .nav-pills .nav-link.active {
    background: #5DA8CB20;
    border-color: #5DA8CB50;
    color: #7DC8EB;
}

/* Manage layout adjustments */
.identity-main .row {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.identity-main .row .col-md-3,
.identity-main .row .col-md-4,
.identity-main .row .col-md-6,
.identity-main .row .col-md-9 {
    width: 100%;
    max-width: 100%;
    flex: none;
    padding: 0;
}

/* ============================================
   ERROR PAGES (Access Denied, Lockout)
   ============================================ */
.identity-main header {
    text-align: center;
    padding: 2rem;
}

.identity-main header h1.text-danger {
    color: #DCA26E !important;
    margin-bottom: 1rem;
}

.identity-main header p.text-danger {
    color: #DCA26E !important;
    opacity: 0.8;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 576px) {
    .identity-container {
        padding: 1rem 0.75rem;
        align-items: flex-start;
        padding-top: 2rem;
    }
    
    .identity-main > div,
    .identity-main > section,
    .identity-main > form,
    .identity-main > .row > div {
        padding: 1.75rem 1.25rem;
        border-radius: 12px;
    }
    
    .identity-main h1 {
        font-size: 1.5rem;
    }
    
    .identity-main .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .identity-navbar {
        padding: 0.75rem 0;
    }
    
    .identity-navbar .brand-text {
        font-size: 1.25rem;
    }
    
    .identity-user-status {
        right: 0.75rem;
    }
    
    .identity-home-link {
        left: 0.75rem;
        width: 36px;
        height: 36px;
    }
    
    .identity-user-link {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
        max-width: 120px;
    }
    
    .identity-user-link span {
        display: none;
    }
    
    .identity-logout-btn {
        width: 32px;
        height: 32px;
    }
    
    .identity-header-logo {
        max-width: 120px;
    }
}

@media (min-width: 768px) {
    .identity-main .nav-pills {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .identity-main .nav-pills .nav-link {
        padding: 0.65rem 1rem;
        font-size: 0.85rem;
    }
}

/* ============================================
   ADDITIONAL OVERRIDES
   ============================================ */
/* Remove Bootstrap default form-control background */
.identity-main .form-control:disabled,
.identity-main .form-control[readonly] {
    background-color: #181818 !important;
    opacity: 0.6;
    cursor: not-allowed;
}

/* Fix for Bootstrap columns in Identity pages */
.identity-main .col-12,
.identity-main .col-lg-8 {
    width: 100%;
    max-width: 100%;
    padding: 0;
}

/* Two-column layout for larger screens on manage pages */
@media (min-width: 992px) {
    .identity-main {
        max-width: 600px;
    }
}

/* ---------------------------------------------------------------------------
   Nibbles CAPTCHA (Register page)

   NOTE ON SPECIFICITY — this is why the first attempt looked "overwritten":
   this file styles the Identity area with descendant selectors like
   `.identity-main h4` (0,1,1) and `.identity-main p` (0,1,1). A bare utility class
   such as `.textaccent2` (0,1,0) LOSES to those. So every rule below is scoped with
   `.identity-main` to win on specificity rather than reaching for !important.
   --------------------------------------------------------------------------- */

/* "Crea un nuovo account" — foreground, H2. Beats `.identity-main h2`. */
.identity-main .reg-title {
    color: var(--eudhos-text-primary, #eeeeee);
    text-align: center;
    margin-bottom: 1rem;
}

/* "Hai vinto!" — accent1, H2. Hidden until win(); beats `.identity-main h2`. */
.identity-main .reg-win-title {
    color: var(--eudhos-accent1, #5DA8CB);
    text-align: center;
    margin-bottom: .5rem;
}

/* "Per registrarti, prova che sei un umano." — accent2, H4.
   Without .identity-main here, `.identity-main h4 { color:#aaaaaa }` wins and the
   accent is silently lost. */
.identity-main .reg-ask {
    color: var(--eudhos-accent2, #71E1D4);
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: .4rem;
}

/* "Risolvi il gioco..." / the win message — foreground, .textdesc typography.
   Beats `.identity-main p { color:#aaaaaa; }`. */
.identity-main .reg-desc {
    color: var(--eudhos-text-primary, #eeeeee);
    text-align: center;      /* .textdesc justifies; a centred one-liner needs this */
    white-space: pre-line;   /* keeps the win message's line breaks */
    margin-bottom: 1.25rem;
}

.identity-main .nib-wrap {
    margin: 0 auto 1.25rem;
}

.identity-main .nib-box {
    position: relative;
    line-height: 0;          /* kills the inline-block gap under the canvas */
}

.identity-main .nib-box canvas {
    width: 100%;
    height: auto;
    display: block;
    image-rendering: pixelated;   /* keep the blocks crisp when scaled */
    outline: none;
    touch-action: none;           /* taps steer the snake; don't scroll the page */
    cursor: pointer;
}

/* Sits over the arena for Inizia / Riprova, and gets out of the way while playing. */
.identity-main .nib-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    /* Fully opaque: at 55% the snake showed through under the button and looked messy. */
    background: var(--eudhos-bg-dark, #0a0a0a);
    line-height: 1.4;
    z-index: 2;
}

.identity-main .nib-overlay[hidden] { display: none; }

.identity-main .nib-msg {
    color: var(--eudhos-accent1, #5DA8CB);
    font-family: "Courier New", Courier, monospace;
    font-size: 1rem;
    letter-spacing: 1px;
    text-align: center;
    text-shadow: 0 0 6px rgba(93, 168, 203, 0.35);
}

.identity-main .nib-msg:empty { display: none; }

/* Old-terminal button: square, monospace, phosphor glow. No rounding on purpose.
   Scoped with .identity-main so `.identity-main .btn` rules can't reshape it. */
.identity-main .nib-btn {
    font-family: "Courier New", Courier, monospace;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--eudhos-accent2, #71E1D4);
    background: transparent;
    border: 2px solid var(--eudhos-accent2, #71E1D4);
    border-radius: 0;
    padding: .5rem 1.75rem;
    width: auto;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
    text-shadow: 0 0 8px rgba(113, 225, 212, 0.5);
    box-shadow: 0 0 10px rgba(113, 225, 212, 0.18), inset 0 0 10px rgba(113, 225, 212, 0.08);
}

.identity-main .nib-btn:hover,
.identity-main .nib-btn:focus-visible {
    background: var(--eudhos-accent2, #71E1D4);
    color: #0a0a0a;
    text-shadow: none;
    box-shadow: 0 0 18px rgba(113, 225, 212, 0.55);
    outline: none;
}

/* Controls hint — accent1, centred, same terminal voice as the rest of the game. */
.identity-main .nib-instructions {
    color: var(--eudhos-accent1, #5DA8CB);
    font-family: "Courier New", Courier, monospace;
    font-size: .95rem;
    letter-spacing: 1px;
    text-align: center;
    margin: 1rem 0 .5rem;
}

/* Esci — a quiet way out, not a call to action. Same terminal shape as .nib-btn,
   deliberately toned down to gray so it never competes with Inizia/Riprova. */
.identity-main .nib-btn-exit {
    display: block;
    margin: .75rem auto 0;
    color: var(--eudhos-text-muted, #777777);
    border-color: var(--eudhos-text-muted, #777777);
    text-shadow: none;
    box-shadow: none;
    font-size: .9rem;
    letter-spacing: 2px;
    padding: .4rem 1.5rem;
}

.identity-main .nib-btn-exit:hover,
.identity-main .nib-btn-exit:focus-visible {
    background: var(--eudhos-text-muted, #777777);
    color: #0a0a0a;
    text-shadow: none;
    box-shadow: 0 0 12px rgba(119, 119, 119, 0.4);
    outline: none;
}
