/*
 * MGC Webcam Styles
 * Wird nur auf Posts der Kategorie 'webcams' geladen.
 * Enqueue: functions.php Section 18b
 *
 * Inhalt:
 *   1  Webcam-Liste Legacy  (#webcams)
 *   2  Webcam-Übersichtsraster  (.mygc-webcam-grid)
 *   3  Webcam-Liste Neu  (.mygc-webcams)
 *   4  Lightbox  (#mygc-webcam-dialog)
 *   5  Responsive
 */


/* ==========================================================================
   1.  WEBCAM-LISTE LEGACY  (#webcams)
   Für noch nicht aktualisierte Seiten mit altem HTML-Code.
   Kein JS-Rebuild nötig: onclick="webcam.getNewImg(…)" navigiert bei
   fehlendem JS einfach zur Bild-URL – akzeptables Fallback-Verhalten.
   ========================================================================== */

#webcams {
    list-style:     none;
    padding:        0;
    margin:         1.5rem 0;
    display:        flex;
    flex-direction: column;
    gap:            1rem;
}

#webcams > li {
    padding:        0.875rem 1rem 0;
    background:     var(--wp--preset--color--taoi-box);
    border:         1px solid #c8d8e8;
    border-radius:  6px;
    overflow:       hidden;
    font-size:      var(--wp--preset--font-size--small);
    line-height:    1.55;
}

#webcams > li > .loading {
    display: none;
}

#webcams > li > a:first-of-type {
    display: block;
    float:   left;
    margin:  0 1rem 0.5rem 0;
}

#webcams > li > a:first-of-type img {
    display:       block;
    width:         140px;
    height:        auto;
    border-radius: 4px;
    border:        1px solid #c8d8e8;
    transition:    opacity 0.15s ease;
}

#webcams > li > a:first-of-type:hover img {
    opacity: 0.82;
}

#webcams > li > a:nth-of-type(2) {
    display:         block;
    font-weight:     700;
    font-size:       var(--wp--preset--font-size--base);
    color:           var(--wp--preset--color--link-blue);
    text-decoration: underline;
    margin-bottom:   0.25rem;
    line-height:     1.3;
}

#webcams > li > a:nth-of-type(2):hover {
    text-decoration: none;
    color:           #0000cc;
}

#webcams > li > ul {
    list-style:  none;
    margin:      0.75rem -1rem 0;
    padding:     0.5rem 1rem;
    clear:       both;
    display:     flex;
    flex-wrap:   wrap;
    align-items: center;
    gap:         0 0.375rem;
    font-size:   var(--wp--preset--font-size--x-small);
    color:       var(--wp--preset--color--politics-gray);
    border-top:  1px solid #c8d8e8;
    background:  rgba(255, 255, 255, 0.50);
}

#webcams > li > ul li {
    display:     flex;
    align-items: center;
    gap:         0 0.25rem;
}

#webcams > li > ul li.courtesy::before {
    content:      "|";
    margin-right: 0.25rem;
    color:        #c5c8cc;
}

#webcams > li > ul a {
    color:           var(--wp--preset--color--link-blue);
    text-decoration: underline;
}

#webcams > li > ul a:hover {
    text-decoration: none;
}

#webcams .arrow {
    color: var(--wp--preset--color--politics-gray);
}

#webcams > li > .clear {
    clear:    both;
    height:   0;
    overflow: hidden;
}


/* ==========================================================================
   2.  WEBCAM-ÜBERSICHTSRASTER  (.mygc-webcam-grid)
   ========================================================================== */

.mygc-webcam-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap:                   0.75rem;
    margin-block:          1.5rem;
}

.mygc-webcam-item {
    margin:        0;
    overflow:      hidden;
    border-radius: 4px;
    border:        1px solid #e3e5e7;
    background:    #f5f7fa;
}

.mygc-webcam-item a {
    display:         block;
    aspect-ratio:    16 / 9;
    overflow:        hidden;
    text-decoration: none;
}

.mygc-webcam-item img {
    display:    block;
    width:      100%;
    height:     100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.mygc-webcam-item:hover img {
    transform: scale(1.04);
}

.mygc-webcam-item figcaption {
    padding:     0.375rem 0.5rem;
    font-size:   var(--wp--preset--font-size--x-small);
    color:       var(--wp--preset--color--politics-gray);
    line-height: 1.35;
}


/* ==========================================================================
   3.  WEBCAM-LISTE NEU  (.mygc-webcams)
   Für Seiten, die bereits auf neuen HTML-Code aktualisiert wurden.
   ========================================================================== */

.mygc-webcams {
    list-style:     none;
    padding:        0;
    margin:         1.5rem 0;
    display:        flex;
    flex-direction: column;
    gap:            1rem;
}

.mygc-webcams > li {
    padding:       0.875rem 1rem 0;
    background:    var(--wp--preset--color--taoi-box);
    border:        1px solid #c8d8e8;
    border-radius: 6px;
    overflow:      hidden;
    font-size:     var(--wp--preset--font-size--small);
    line-height:   1.55;
}

.mygc-webcams > li > a.mygc-webcam-link:first-of-type {
    display: block;
    float:   left;
    margin:  0 1rem 0.5rem 0;
}

.mygc-webcams > li > a.mygc-webcam-link:first-of-type img {
    display:       block;
    width:         140px;
    height:        auto;
    border-radius: 4px;
    border:        1px solid #c8d8e8;
    transition:    opacity 0.15s ease;
}

.mygc-webcams > li > a.mygc-webcam-link:first-of-type:hover img {
    opacity: 0.82;
}

.mygc-webcams > li > a.mygc-webcam-link:nth-of-type(2) {
    display:         block;
    font-weight:     700;
    font-size:       var(--wp--preset--font-size--base);
    color:           var(--wp--preset--color--link-blue);
    text-decoration: underline;
    margin-bottom:   0.25rem;
    line-height:     1.3;
}

.mygc-webcams > li > a.mygc-webcam-link:nth-of-type(2):hover {
    text-decoration: none;
    color:           #0000cc;
}

.mygc-webcam-meta {
    list-style:  none;
    margin:      0.75rem -1rem 0;
    padding:     0.5rem 1rem;
    clear:       both;
    display:     flex;
    flex-wrap:   wrap;
    align-items: center;
    gap:         0 0.375rem;
    font-size:   var(--wp--preset--font-size--x-small);
    color:       var(--wp--preset--color--politics-gray);
    border-top:  1px solid #c8d8e8;
    background:  rgba(255, 255, 255, 0.50);
}

.mygc-webcam-meta li {
    display:     flex;
    align-items: center;
    gap:         0 0.25rem;
}

.mygc-webcam-meta li.courtesy::before {
    content:      "|";
    margin-right: 0.25rem;
    color:        #c5c8cc;
}

.mygc-webcam-meta a {
    color:           var(--wp--preset--color--link-blue);
    text-decoration: underline;
}

.mygc-webcam-meta a:hover {
    text-decoration: none;
}


/* ==========================================================================
   4.  LIGHTBOX  (#mygc-webcam-dialog)
   <dialog>-Element wird per webcam-lightbox.js ins DOM eingefügt.
   ========================================================================== */

#mygc-webcam-dialog {
    padding:       0;
    border:        none;
    border-radius: 6px;
    background:    #1a1a1a;
    color:         #e0e0e0;
    max-width:     min(92vw, 900px);
    max-height:    92vh;
    overflow:      hidden;
    box-shadow:    0 8px 40px rgba(0, 0, 0, 0.7);
}

#mygc-webcam-dialog::backdrop {
    background: rgba(0, 0, 0, 0.85);
}

#mygc-webcam-dialog .dlg-close {
    position:        absolute;
    top:             8px;
    right:           8px;
    z-index:         1;
    width:           28px;
    height:          28px;
    display:         flex;
    align-items:     center;
    justify-content: center;
    border-radius:   50%;
    border:          none;
    background:      rgba(255, 255, 255, 0.15);
    color:           #fff;
    font-size:       0.875rem;
    cursor:          pointer;
    transition:      background 0.15s ease;
}

#mygc-webcam-dialog .dlg-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

#mygc-webcam-dialog .dlg-img-wrap {
    display:         flex;
    align-items:     center;
    justify-content: center;
    padding:         2.5rem 1rem 1rem;
    min-height:      120px;
}

#mygc-webcam-dialog #dlg-img {
    display:       block;
    max-width:     100%;
    max-height:    calc(85vh - 70px);
    height:        auto;
    border-radius: 2px;
    transition:    opacity 0.2s ease;
}

#mygc-webcam-dialog #dlg-img.is-loading {
    opacity: 0.25;
}

#mygc-webcam-dialog .dlg-bar {
    display:      flex;
    align-items:  center;
    gap:          0.5rem;
    padding:      0.5rem 0.75rem;
    border-top:   1px solid #333;
    background:   #111;
}

#mygc-webcam-dialog .dlg-prev,
#mygc-webcam-dialog .dlg-next {
    flex-shrink:     0;
    width:           32px;
    height:          32px;
    display:         flex;
    align-items:     center;
    justify-content: center;
    border:          1px solid #444;
    border-radius:   50%;
    background:      transparent;
    color:           #e0e0e0;
    font-size:       1.25rem;
    cursor:          pointer;
    transition:      background 0.15s ease, color 0.15s ease;
}

#mygc-webcam-dialog .dlg-prev:hover:not(:disabled),
#mygc-webcam-dialog .dlg-next:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    color:      #fff;
}

#mygc-webcam-dialog .dlg-prev:disabled,
#mygc-webcam-dialog .dlg-next:disabled {
    opacity: 0.3;
    cursor:  default;
}

#mygc-webcam-dialog .dlg-info {
    flex:        1;
    text-align:  center;
    font-size:   0.8125rem;
    line-height: 1.35;
}

#mygc-webcam-dialog .dlg-title {
    font-weight: 600;
}

#mygc-webcam-dialog .dlg-counter {
    margin-left: 0.4rem;
    opacity:     0.55;
    font-size:   0.75rem;
}


/* ==========================================================================
   5.  RESPONSIVE
   ========================================================================== */

/* Webcam-Raster: mindestens 2 Spalten auf sehr kleinen Screens */
@media (max-width: 399px) {
    .mygc-webcam-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Legacy- und neue Liste: Float aufheben auf Smartphones */
@media (max-width: 540px) {
    #webcams > li > a:first-of-type,
    .mygc-webcams > li > a.mygc-webcam-link:first-of-type {
        float:  none;
        margin: 0 0 0.75rem;
    }
    #webcams > li > a:first-of-type img,
    .mygc-webcams > li > a.mygc-webcam-link:first-of-type img {
        width:     100%;
        max-width: 280px;
    }
}