/*
Theme Name: TEST
Theme URI: https://yourdomain.com
Author: Your Name
Author URI: https://yourdomain.com
Description: A modern iOS App Store inspired WordPress theme.
Version: 1.0.4
*/

/* ========================================
   CSS VARIABLES - iOS Design System
======================================== */
:root {
    --ios-bg: #F5F5F7;
    --ios-text: #1D1D1F;
    --ios-blue: #007AFF;
    --ios-gray: #86868B;
    --ios-light-gray: #C7C7CC;
    --ios-card-bg: #FFFFFF;
    --sidebar-width: 290px;
    --sidebar-bg: #E8E8ED;
    --mobile-header-height: 56px;
}

/* ========================================
   RESET & BASE STYLES
======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Removes blue highlight on mobile tap */
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--ios-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--ios-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a {
    color: var(--ios-blue);
    text-decoration: none;
    transition: opacity 0.2s;
}

a:hover {
    opacity: 0.8;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input,
textarea,
select {
    font-family: inherit;
}

/* ========================================
   FIXED SIDEBAR LAYOUT
======================================== */

/* Desktop: Main content area with left margin for fixed sidebar */
@media (min-width: 769px) {
    .ios-store-layout,
    .home-wrapper,
    .as-wrapper {
        margin-left: var(--sidebar-width);
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .store-content,
    .home-content,
    .as-main {
        flex: 1;
        margin-left: 0;
        max-width: 100%;
    }
}

/* Mobile: No margin, sidebar is overlay */
@media (max-width: 768px) {
    .ios-store-layout,
    .home-wrapper,
    .as-wrapper {
        margin-left: 0;
        padding-top: var(--mobile-header-height);
    }
    
    body.sidebar-open {
        overflow: hidden;
    }
}

/* ========================================
   LAYOUT WRAPPER
======================================== */
.ios-store-layout,
.home-wrapper,
.as-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--ios-bg);
}

/* ========================================
   MAIN CONTENT AREA
======================================== */
.store-content,
.home-content,
.as-main {
    flex: 1;
    padding: 40px;
    overflow-x: hidden;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    margin-bottom: 30px;
}

.page-title,
.as-section-title {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #000;
    letter-spacing: -0.5px;
}

.page-subtitle,
.as-section-subtitle {
    font-size: 16px;
    color: var(--ios-gray);
    margin: 0;
}

.section-title {
    font-size: 28px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0 0 20px 0;
    letter-spacing: -0.5px;
}

.section-subtitle {
    font-size: 15px;
    color: #86868b;
    margin: -15px 0 25px 0;
}

/* ========================================
   APPS GRID LAYOUT
======================================== */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

/* ========================================
   APP CARD DESIGN
======================================== */
.ios-app-card {
    background: #FFFFFF;
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Hover effects only on Desktop */
@media (min-width: 769px) {
    .ios-app-card:hover {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.06);
        transform: translateY(-2px);
    }
}

.card-link-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    text-decoration: none;
    outline: none; /* No outline on link itself */
}

/* Card Header */
.card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 1;
}

.app-icon-wrapper {
    flex-shrink: 0;
}

.app-icon {
    width: 68px;
    height: 68px;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    object-fit: cover;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.app-details-mini {
    flex: 1;
    min-width: 0;
}

.app-name {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 3px 0;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-subtitle {
    font-size: 12px;
    color: var(--ios-gray);
    margin: 0 0 6px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-rating {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stars {
    display: flex;
    gap: 2px;
}

.star {
    font-size: 13px;
    color: #E5E5EA;
}

.star.filled {
    color: #FFD700;
    text-shadow: 0 1px 2px rgba(255, 215, 0, 0.3);
}

.rating-count {
    font-size: 12px;
    color: #8e8e93;
    font-weight: 500;
}

.app-action {
    flex-shrink: 0;
}

.btn-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #F0F0F5;
    color: var(--ios-blue);
    font-size: 15px;
    font-weight: 600;
    padding: 7px 22px;
    border-radius: 50px;
    text-decoration: none;
    letter-spacing: -0.3px;
    min-width: 72px;
    height: 32px;
    box-sizing: border-box;
}

/* Screenshots Section */
.card-screenshots {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.screenshot-container {
    flex: 1;
    aspect-ratio: 9/19.5;
    border-radius: 10px;
    overflow: hidden;
    background: #FAFAFA;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.screenshot-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.screenshot-container.placeholder {
    background: #F8F8F8;
    opacity: 0.6;
}

.no-screenshots {
    width: 100%;
    text-align: center;
    padding: 30px 20px;
    color: #8e8e93;
    font-size: 13px;
    background: #FAFAFA;
    border-radius: 10px;
    font-weight: 500;
}

/* ========================================
   ARCHIVE/LIST CARD STYLES
======================================== */
.as-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.as-card {
    display: flex;
    align-items: center;
    padding: 15px;
    border-radius: 16px;
    text-decoration: none !important;
    background-color: #FFFFFF !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 1px solid rgba(0,0,0,0.05);
}

@media (min-width: 769px) {
    .as-card:hover {
        background-color: #FFFFFF;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
        transform: translateY(-2px);
    }
}

.as-card:active {
    background-color: #E8E8ED !important;
    transform: scale(0.98);
}

.as-icon {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    object-fit: cover;
    margin-right: 15px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.as-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.as-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ios-text);
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.as-desc {
    font-size: 13px;
    color: var(--ios-gray);
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.as-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--ios-gray);
    margin-top: 2px;
}

.as-btn {
    background: #F0F0F5;
    color: var(--ios-blue);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 18px;
    border-radius: 20px;
    text-transform: uppercase;
    margin-left: 10px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* ========================================
   SECTION HEADERS
======================================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 50px 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.section-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: #000;
}

.section-header .see-all {
    font-size: 14px;
    color: var(--ios-blue);
    text-decoration: none;
    font-weight: 600;
}

.section-header .see-all:hover {
    text-decoration: underline;
}

/* ========================================
   NO RESULTS
======================================== */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #8e8e93;
}

.no-results h2 {
    font-size: 24px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 10px;
}

.no-results p {
    font-size: 16px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--ios-gray);
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: var(--ios-text);
}

/* ========================================
   PAGINATION
======================================== */
.store-pagination,
.as-pagination {
    margin-top: 40px;
    text-align: center;
    padding: 30px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.store-pagination .nav-links,
.as-pagination .nav-links {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.store-pagination .page-numbers,
.as-pagination a,
.as-pagination .current {
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ios-text);
    font-weight: 500;
    transition: all 0.2s;
    display: inline-block;
}

.store-pagination .page-numbers:hover,
.as-pagination a:hover {
    background: #f5f5f7;
}

.store-pagination .page-numbers.current,
.as-pagination .current {
    background: var(--ios-blue);
    color: #fff;
    border-color: var(--ios-blue);
    font-weight: 600;
}

.store-pagination .prev,
.store-pagination .next {
    font-weight: 600;
}

/* ========================================
   SIMILAR RESULTS NOTICE
======================================== */
.similar-results-notice {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #FFF3CD 0%, #FFF8E1 100%);
    border-left: 4px solid #FFC107;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.similar-results-notice p {
    margin: 0;
    color: #856404;
    font-size: 15px;
}

.similar-results-notice strong {
    color: #533f03;
}

/* ========================================
   WORDPRESS SPECIFIC STYLES
======================================== */
.alignleft {
    float: left;
    margin-right: 20px;
    margin-bottom: 10px;
}

.alignright {
    float: right;
    margin-left: 20px;
    margin-bottom: 10px;
}

.aligncenter {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.wp-caption {
    max-width: 100%;
}

.wp-caption-text {
    font-size: 13px;
    color: var(--ios-gray);
    padding: 8px 0;
    text-align: center;
}

.sticky {
    /* Sticky post styles */
}

.bypostauthor {
    /* Post author styles */
}

/* Screen reader text */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    word-wrap: normal !important;
}

.screen-reader-text:focus {
    background-color: #f1f1f1;
    border-radius: 3px;
    box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
    clip: auto !important;
    color: #21759b;
    display: block;
    font-size: 14px;
    font-weight: bold;
    height: auto;
    left: 5px;
    line-height: normal;
    padding: 15px 23px 14px;
    text-decoration: none;
    top: 5px;
    width: auto;
    z-index: 100000;
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */

/* Large Tablets */
@media (max-width: 1100px) {
    .as-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablets */
@media (max-width: 1024px) {
    .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 20px;
    }
    
    .store-content,
    .home-content,
    .as-main {
        padding: 30px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .store-content,
    .home-content,
    .as-main {
        padding: 20px;
    }
    
    .page-title,
    .as-section-title {
        font-size: 24px;
    }
    
    .section-title {
        font-size: 22px;
    }
    
    .apps-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .as-grid {
        grid-template-columns: 1fr;
    }
    
    .ios-app-card {
        padding: 14px;
    }
    
    .card-header {
        gap: 12px;
    }
    
    .app-icon {
        width: 60px;
        height: 60px;
        border-radius: 14px;
    }
    
    .app-name,
    .as-title {
        font-size: 14px;
    }
    
    .app-subtitle,
    .as-desc {
        font-size: 11px;
    }
    
    .screenshot-container {
        border-radius: 8px;
    }
    
    .section-header {
        margin: 30px 0 15px 0;
    }
    
    .section-header h2 {
        font-size: 18px;
    }
    
    .as-icon {
        width: 56px;
        height: 56px;
        border-radius: 12px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .store-content,
    .home-content,
    .as-main {
        padding: 16px;
    }
    
    .page-title,
    .as-section-title {
        font-size: 20px;
    }
    
    .card-screenshots {
        gap: 8px;
    }
    
    .btn-view,
    .as-btn {
        font-size: 13px;
        padding: 6px 18px;
        min-width: 64px;
        height: 28px;
    }
    
    .section-header h2 {
        font-size: 16px;
    }
}

/* ========================================
   PRINT STYLES
======================================== */
@media print {
    .mobile-header,
    .store-sidebar,
    .store-pagination,
    .as-pagination,
    .btn-view,
    .as-btn,
    .back-to-top {
        display: none;
    }
    
    .store-content,
    .home-content,
    .as-main {
        padding: 0;
        margin-left: 0;
    }
    
    .ios-app-card,
    .as-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .ios-footer {
        margin-left: 0;
    }
}

/* ========================================
   ACCESSIBILITY - FIXED
======================================== */
/* Only show outline on keyboard focus, hide on mouse/touch */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--ios-blue);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .ios-app-card,
    .as-card {
        border: 2px solid var(--ios-text);
    }
    
    .btn-view,
    .as-btn {
        border: 2px solid var(--ios-blue);
    }
}

/* ========================================
   DARK MODE SUPPORT (Optional)
======================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --ios-bg: #000000;
        --ios-text: #F5F5F7;
        --ios-card-bg: #1C1C1E;
        --sidebar-bg: #1C1C1E;
        --mobile-header-bg: #1C1C1E;
    }
    
    body {
        background-color: var(--ios-bg);
        color: var(--ios-text);
    }
    
    .ios-app-card,
    .as-card {
        background: var(--ios-card-bg);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .app-name,
    .as-title {
        color: #fff;
    }
    
    .btn-view,
    .as-btn {
        background: #2C2C2E;
    }
    
    .screenshot-container,
    .screenshot-container.placeholder {
        background: #2C2C2E;
    }
    
    .page-title,
    .section-title,
    .section-header h2 {
        color: #fff;
    }
}

/* ========================================
   UTILITY CLASSES
======================================== */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

.no-scroll {
    overflow: hidden;
}

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* ========================================
   LOADING STATES
======================================== */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 40px auto;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--ios-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   CUSTOM SCROLLBAR (Webkit only)
======================================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #C7C7CC;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #86868b;
}

/* ========================================
   SELECTION
======================================== */
::selection {
    background: var(--ios-blue);
    color: #fff;
}

::-moz-selection {
    background: var(--ios-blue);
    color: #fff;
}