/* 
 * ==============================================
 *      MATERIAL YOU (M3) THEME & PALETTE
 *  (Combined for both applications)
 * ==============================================
 */
:root {
    --font-family-main: 'Roboto', sans-serif;
    
    /* Primary Colors (Used by both) */
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;

    /* Secondary Colors (Used by Calculator) */
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-on-secondary-container: #1D192B;

    /* Tertiary Colors (Used by Calculator) */
    --md-sys-color-tertiary-container: #F3EDF7;
    --md-sys-color-on-tertiary-container: #1D1B20;
    
    /* Surface & Background Colors (Used by both) */
    --md-sys-color-surface: #FEF7FF;
    --md-sys-color-on-surface: #1D1B20;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-surface-container: #F3EDF7;      /* For RNG input background */
    --md-sys-color-surface-container-high: #ECE6F0; /* For RNG input focus */
    --md-sys-color-background: #FEF7FF;
    --md-sys-color-outline: #79747E;                 /* For RNG input border */

    /* Shape & Corner Radius */
    --md-sys-shape-corner-large: 28px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-medium: 16px;
    --md-sys-shape-corner-small: 12px;
}

/* 
 * ==============================================
 *          GLOBAL & SHARED STYLES
 * ==============================================
 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: var(--font-family-main);
    background-color: var(--md-sys-color-background);
    display: grid;
    place-items: center;
    padding: 1rem;
    overflow: hidden; /* Prevents scrollbars on both apps */
}

/* Shared Ripple Effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple-effect 0.6s linear;
    pointer-events: none;
    /* Default ripple color (for light buttons) */
    background-color: rgba(0, 0, 0, 0.2); 
}

@keyframes ripple-effect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Override for dark buttons to show a light ripple */
.generate-btn .ripple,
.btn.btn-equals .ripple {
    background-color: rgba(255, 255, 255, 0.7);
}


/* 
 * ==============================================
 *      RANDOM NUMBER GENERATOR STYLES
 * ==============================================
 */
.generator-card {
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: card-enter 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(30px);
}

@keyframes card-enter {
    to { opacity: 1; transform: translateY(0); }
}

.card-header h1 {
    font-size: 28px;
    font-weight: 400;
    color: var(--md-sys-color-on-surface);
    text-align: center;
}

.result-display {
    font-size: 57px;
    font-weight: 400;
    line-height: 1.1;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 16px 24px;
    border-radius: var(--md-sys-shape-corner-medium);
    min-width: 120px;
    min-height: 80px;
    display: grid;
    place-items: center;
    text-align: center;
    transition: transform 0.2s ease;
}

.result-display.pop {
    animation: pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-in {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.input-controls { display: flex; gap: 16px; width: 100%; }

.text-field {
    position: relative;
    background-color: var(--md-sys-color-surface-container);
    border-top-left-radius: var(--md-sys-shape-corner-small);
    border-top-right-radius: var(--md-sys-shape-corner-small);
    padding: 24px 16px 8px 16px;
    flex: 1;
    border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.text-field:focus-within {
    border-bottom: 2px solid var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-container-high);
}

.text-field label {
    position: absolute;
    top: 26px; left: 16px;
    font-size: 16px;
    color: var(--md-sys-color-on-surface-variant);
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: left top;
}

.text-field input {
    font-family: inherit;
    font-size: 16px;
    width: 100%;
    border: none;
    background-color: transparent;
    color: var(--md-sys-color-on-surface);
    outline: none;
}

.text-field input:focus + label,
.text-field input:not(:placeholder-shown) + label {
    transform: translateY(-16px) scale(0.75);
    color: var(--md-sys-color-primary);
}

input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.generate-btn {
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    border-radius: 100px;
    padding: 10px 24px;
    cursor: pointer;
    width: 100%;
    height: 40px;
    transition: box-shadow 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
}

.generate-btn:hover {
    box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 2px 6px 2px rgba(0,0,0,0.15);
}

.generate-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
}


/* 
 * ==============================================
 *          CALCULATOR STYLES
 * ==============================================
 */
.calculator-card {
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 24px;
    width: 100%;
    max-width: 420px;
    min-height: 600px;
    box-shadow: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

.calculator-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 24px;
    margin-bottom: 16px;
    word-wrap: break-word;
    word-break: break-all;
}

.previous-operand {
    font-size: 22px;
    font-weight: 400;
    color: var(--md-sys-color-on-surface-variant);
    min-height: 32px;
}

.current-operand {
    font-size: 57px;
    font-weight: 400;
    color: var(--md-sys-color-on-surface);
}

.calculator-keys {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.btn {
    font-family: inherit;
    font-size: 22px;
    font-weight: 500;
    border: none;
    border-radius: var(--md-sys-shape-corner-extra-large);
    height: 72px;
    display: grid;
    place-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn.btn-number {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
}
.btn.btn-operator {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-size: 28px;
}
.btn.btn-function {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}
.btn.btn-equals {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    grid-column: span 2;
}

/* 
 * ==============================================
 *          HOME MENU (INDEX.HTML) STYLES
 * ==============================================
 */
.menu-card {
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 24px;
    width: 100%;
    max-width: 400px; /* Same as RNG for consistency */
    box-shadow: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    /* Entrance Animation for consistency */
    animation: card-enter 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(30px);
}

.menu-card h1 {
    font-size: 28px;
    font-weight: 400;
    color: var(--md-sys-color-on-surface);
    text-align: center;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.menu-btn {
    display: block;
    font-family: inherit;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.1px;
    text-decoration: none;
    text-align: center;
    /* Using secondary container for a distinct but harmonious look */
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border: none;
    border-radius: 100px;
    padding: 16px 24px;
    cursor: pointer;
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
    /* Required for ripple effect */
    position: relative;
    overflow: hidden;
}

.menu-btn:hover {
    box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 2px 6px 2px rgba(0,0,0,0.15);
    background-color: #E0D5F1; /* A slightly darker shade for hover */
}

.menu-btn:active {
    transform: translateY(1px);
}
