/* =========================================
   1. GLOBAL RESET & VARIABLES
   ========================================= */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --text-main: #1f2937;
    --text-light: #6b7280;
    --bg-body: #ffffff;
    --white: #ffffff;
    --win-bg: #111827;
    --mac-bg: #081735;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden; /* Horizontal scroll prevention */
}

a { text-decoration: none; color: inherit; transition: 0.3s; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* =========================================
   2. HEADER & HERO
   ========================================= */
.site-header {
    background: var(--white);
    height: 70px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky; top: 0; z-index: 1000;
    background-color: #1a0555;
}
.navbar { display: flex; justify-content: space-between; align-items: center; height: 100%; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; color: var(--primary); }
.nav-menu { display: flex; gap: 30px; }
.nav-link { font-weight: 500; color:white; }
.nav-link:hover, .nav-link.active { color:white; }
.hamburger { display: none; cursor: pointer;}
.bar { display: block; width: 25px; height: 3px; margin: 5px auto; background-color: white; transition: 0.3s; }

/* Mobile Menu */
@media (max-width: 768px) {
    .hamburger { display: block; }
    .nav-menu {
        position: fixed; left: -100%; top: 70px; flex-direction: column;
        background-color: var(--white); width: 100%; height: 100%; text-align: center;
        padding: 20px 0; box-shadow: 0 4px 6px rgba(226, 216, 216, 0.05); transition: 0.3s;
    }
    .nav-menu.active { left: 0; background-color: #081735; }
    .nav-item { margin: 15px 0; }
}

.hero-section { text-align: center; padding: 40px 0 20px; }
.hero-section h1 { font-size: 2rem; font-weight: 800; color: var(--text-main); margin-bottom: 10px; }
.hero-section p { font-size: 1rem; color: var(--text-light); max-width: 600px; margin: 0 auto; }

/* Ad Container */
.ad-container {
    background: #f3f4f6; border: 1px dashed #d1d5db; min-height: 100px;
    margin: 20px auto; display: flex; flex-direction: column;
    justify-content: center; align-items: center; border-radius: 8px; max-width: 728px;
}
.ad-label { font-size: 0.7rem; color: #9ca3af; text-transform: uppercase; margin-bottom: 5px; }

/* =========================================
   3. TOOL AREA (CONTROLS)
   ========================================= */
.tool-section { padding: 20px 0; margin-bottom: 40px; }

.controls-bar {
    display: flex; justify-content: space-between; align-items: center;
    background: #ffffff; padding: 10px 15px; border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 20px;
    flex-wrap: wrap; gap: 15px;
}

.os-switch-group { display: flex; gap: 8px; background: #f3f4f6; padding: 4px; border-radius: 6px; }
.btn-os { padding: 6px 14px; border-radius: 4px; font-weight: 600; color: #4b5563; background: transparent; border: 1px solid transparent; display: flex; align-items: center; gap: 5px; font-size: 0.9rem; transition: 0.2s; }
.btn-os:hover { background: #e5e7eb; }
.btn-os.active { background: #ffffff; color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

.action-group { display: flex; gap: 10px; align-items: center; }
#last-key-display { font-family: monospace; color: var(--text-light); font-size: 0.85rem; margin-right: 10px; }
.btn-action { background: white; border: 1px solid #d1d5db; padding: 6px 12px; border-radius: 4px; font-weight: 500; font-size: 0.9rem; transition: 0.2s; }
.btn-action:hover { border-color: var(--text-main); }

/* =========================================
   4. KEYBOARD LAYOUT (PC View Default)
   ========================================= */
.keyboard-scroll-wrapper {
    width: 100%;
    display: flex; 
    justify-content: center; /* Center on PC */
    padding-bottom: 10px;
    overflow: visible; /* PC par scroll na ho */
}

.keyboard-body {
    display: inline-block;
    padding: 20px;
    border-radius: 12px;
    user-select: none;
    box-shadow: 0 15px 30px -10px rgba(0, 0, 0, 0.2);
    vertical-align: top;
    text-align: left;
    
    /* Smooth scaling transition */
    transform-origin: top center;
    transition: transform 0.3s ease;
}

.row { display: flex; gap: 4px; margin-bottom: 4px; }

/* --- Key Styling (40px Base) --- */
.key {
    width: 40px; height: 40px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600; cursor: pointer;
    position: relative; top: 0; transition: 0.05s;
}

/* Spacer & Special Widths */
.key-spacer { width: 20px; }
.key.backspace { width: 84px; }
.key.tab { width: 60px; padding-left: 8px; align-items: flex-start; }
.key.caps { width: 70px; padding-left: 8px; align-items: flex-start; }
.key.enter { width: 94px; }
.key.shift-l { width: 94px; }
.key.shift-r { width: 108px; }
.key.ctrl, .key.alt, .key.win, .key.cmd, .key.fn { width: 50px; font-size: 10px; }
.key.space { width: 255px; }

/* =========================================
   5. WINDOWS THEME (Black)
   ========================================= */
.kb-win {
    background-color: var(--win-bg);
    border: 4px solid #1f2937;
    /* Side by Side Layout */
    display: inline-flex; 
    gap: 10px;
    align-items: flex-start;
}

.kb-main, .kb-nav, .kb-numpad { display: flex; flex-direction: column; }
.kb-nav { width: 130px; }
.kb-numpad { padding-left: 10px; border-left: 1px solid #374151; }

.kb-win .key { background-color: #1f2937; color: #f3f4f6; border-bottom: 3px solid #000; }
.kb-win .key:hover { background-color: #374151; }
.kb-win .key.active { background-color: #22c55e; color: #fff; border-bottom: 0px; transform: translateY(3px); }
.kb-win .key.tested { border-color: #15803d; color: #4ade80; }

.row-arrow-pad { display: grid; grid-template-columns: repeat(3, 40px); gap: 4px; margin-top: 20px; }
.row-arrow-pad .key.empty { visibility: hidden; }
.numpad-grid { display: grid; grid-template-columns: repeat(4, 40px); gap: 4px; }
.key.tall { grid-row: span 2; height: 84px; }
.key.wide { grid-column: span 2; width: 84px; }

/* =========================================
   6. MAC THEME (Silver)
   ========================================= */
.kb-mac {
    background-color: var(--mac-bg);
    border: 1px solid #d1d5db;
    display: inline-block;
}
.kb-mac .key { background-color: #fff; color: #374151; border: 1px solid #d1d5db; border-bottom: 2px solid #9ca3af; font-size: 11px; }
.kb-mac .key:hover { background-color: #f9fafb; }
.kb-mac .key.active { background-color: #22c55e; color: #fff; border-bottom: 0px; transform: translateY(2px); border-color: #16a34a; }
.kb-mac .key.tested { background-color: #dcfce7; border-color: #86efac; }
.kb-mac .small-row .key { height: 30px; font-size: 10px; margin-bottom: 6px; }
.mac-arrows { display: flex; flex-direction: column; align-items: center; margin-top: 15px; margin-left: 5px; }
.mac-arrows .sub-row { display: flex; gap: 3px; margin-top: 3px; }
.mac-arrows .key { width: 35px; height: 30px; font-size: 9px; }

/* =========================================
   7. AUTO-SCALING (THE FIX 🛠️)
   Is se keyboard har mobile par fit ayega
   ========================================= */
   
/* Tablet (iPad) */
@media (max-width: 1200px) {
    .keyboard-body { transform: scale(0.9); margin-bottom: -50px; }
}
@media (max-width: 992px) {
    .keyboard-body { transform: scale(0.75); margin-bottom: -100px; }
}

/* Mobile Devices (iPhone/Android) */
@media (max-width: 768px) {
    .keyboard-scroll-wrapper {
        overflow: hidden; /* Scroll khatam */
        display: block; /* Height fix k liye */
        height: 220px; /* Container ki height fix */
        text-align: center;
    }

    .keyboard-body {
        /* Mobile Scaling Logic */
        transform: scale(0.38); /* 38% size kar do */
        transform-origin: top center; /* Center se chota ho */
        
        /* Centering Logic */
        margin-left: 50%; 
        transform: translateX(-50%) scale(0.38);
        
        /* Remove extra white space caused by shrinking */
        margin-bottom: -450px; 
    }
    
    .controls-bar { flex-direction: column; gap: 10px; }
    #last-key-display { width: 100%; text-align: center; }
}

/* Very Small Mobiles (iPhone SE/Galaxy Fold) */
@media (max-width: 380px) {
    .keyboard-body {
        transform: translateX(-50%) scale(0.32); /* Aur chota kar do */
        margin-bottom: -500px;
    }
    .keyboard-scroll-wrapper { height: 180px; }
}


/* =========================================
   8. ARTICLE & FOOTER
   ========================================= */
.content-section { padding: 40px 0; background-color: #fff; border-top: 1px solid #e5e7eb; }
.content-section h2 { font-size: 1.5rem; color: var(--text-main); margin-bottom: 15px; font-weight: 700; }
.content-section h3 { font-size: 1.2rem; margin-top: 20px; font-weight: 600; }
.content-section p { font-size: 1rem; color: #4b5563; margin-bottom: 15px; }

.steps-list { list-style: none; counter-reset: steps-counter; margin-left: 10px; }
.steps-list li { position: relative; padding-left: 40px; margin-bottom: 10px; }
.steps-list li::before { counter-increment: steps-counter; content: counter(steps-counter); position: absolute; left: 0; top: 0; width: 25px; height: 25px; background: var(--primary); color: white; border-radius: 50%; text-align: center; line-height: 25px; font-size: 0.8rem; }

.faq-section { margin-top: 30px; background: #f9fafb; padding: 20px; border-radius: 12px; }
.faq-item { background: white; padding: 15px; border-radius: 8px; margin-bottom: 10px; border: 1px solid #e5e7eb; }
.faq-item h3 { margin: 0 0 5px 0; color: var(--primary); font-size: 1rem; }

.site-footer { background-color: var(--win-bg); color: #d1d5db; padding: 40px 0 20px; margin-top: auto; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 30px; margin-bottom: 30px; }
.footer-col h3 { color: #fff; font-size: 1.1rem; margin-bottom: 15px; border-bottom: 2px solid var(--primary); display: inline-block; padding-bottom: 5px; }
.footer-col ul li { margin-bottom: 8px; }
.footer-col ul li a:hover { color: #fff; padding-left: 5px; }
.footer-bottom { border-top: 1px solid #374151; padding-top: 20px; text-align: center; font-size: 0.9rem; }

#scrollToTopBtn { position: fixed; bottom: 20px; right: 20px; width: 40px; height: 40px; background: var(--primary); color: white; border-radius: 50%; font-size: 1.2rem; display: none; align-items: center; justify-content: center; z-index: 999; }