/*
 * Theme Name: CNCA
 * Author: Code for Recovery
 * Author URI: https://www.cnca06.org
 * Description: A WordPress theme for California Northern Coastal Area 06
 * Text Domain: cnca
 * Version: 1.0.5
 * Tested up to: 5.4
*/

:root {
  --primary-color: #5aafe2;
  --secondary-color: #f87436;
  --background-color: #f5f9f8;
  --border-color: #ddd;
  --link-color: #3d7799;
  --nav-icon-size: 1.4rem;
  --text-color: #333;
  --font-family: ui-sans-serif, system-ui, sans-serif;
}

html {
  &[lang^="en"] .es {
    display: none;
  }
  &[lang^="es"] .en {
    display: none;
  }
}

body {
  background-color: var(--background-color);
  color: var(--text-color);
  font-family: var(--font-family);
  margin: 0;

  * {
    box-sizing: border-box;
  }

  &.admin-bar #cnca nav {
    top: 2rem;

    @media screen and (max-width: 782px) {
      position: static;
    }
  }
}

#cnca {
  background-color: white;
  margin: 0 auto;
  max-width: 75rem;
  position: relative;

  > nav {
    background-color: var(--primary-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-block: 1rem;
    position: sticky;
    top: 0;
    z-index: 9999;

    ul {
      list-style: none;
      margin: 0;
      padding: 0;
    }

    a {
      color: white;
      font-weight: bold;
      letter-spacing: 1px;
      text-align: center;
      text-decoration: none;
    }

    > ul {
      display: none;
      flex-direction: column;

      a {
        display: block;
        padding: 0.75rem 1rem;
        transition: all 0.5s ease;
      }

      > li > a {
        align-items: center;
        display: flex;
        gap: 0.5rem;
        justify-content: center;
        min-height: calc(var(--nav-icon-size) + 1.5rem);
        text-transform: uppercase;
      }

      li:hover > a,
      li.current-menu-item > a {
        background-color: var(--secondary-color);
      }

      > li.menu-item-has-children > a:after {
        content: "▼";
        display: block;
        font-size: 0.75rem;
      }

      > li.lang-item a {
        &::before {
          background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0 1 12 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 0 1 3 12c0-1.605.42-3.113 1.157-4.418' /%3E%3C/svg%3E%0A");
          background-size: contain;
          content: "";
          display: block;
          height: var(--nav-icon-size);
          width: var(--nav-icon-size);
        }
      }
    }

    label {
      cursor: pointer;
      display: block;
      margin: 0 auto;
      width: 2rem;
      span {
        background: white;
        display: block;
        height: 3px;
        margin: 5px 0;
        transition: 0.3s ease;
      }
    }

    #cnca-menu-toggle {
      display: none;
      &:checked {
        ~ label span {
          &:nth-child(1) {
            transform: translateY(0.5rem) rotate(45deg);
          }
          &:nth-child(2) {
            opacity: 0;
          }
          &:nth-child(3) {
            transform: translateY(-0.5rem) rotate(-45deg);
          }
        }
        ~ ul.menu {
          display: flex;
        }
      }
    }
  }

  > header {
    display: flex;
    justify-content: center;
    position: relative;

    svg {
      bottom: 50%;
      color: var(--primary-color);
      position: absolute;
      top: 0;
      width: 100%;
    }

    a {
      cursor: pointer;
      display: block;
      z-index: 1;
      img {
        background-color: white;
        border-radius: 50%;
        height: auto;
        max-width: 100%;
        transition: all 0.3s ease;
        width: 6rem;
        &:hover {
          transform: scale(1.05);
        }
      }
    }
  }

  > main {
    display: grid;
    gap: 4rem;
    padding: 2rem 1rem 5rem;
    grid-template-columns: 1fr;

    a {
      color: var(--link-color);
      font-weight: 500;
      &:hover {
        color: var(--secondary-color);
      }
    }

    form {
      input,
      button[type="submit"] {
        border: 1px solid var(--border-color);
        border-radius: 0.25rem;
        font-size: 1rem;
        padding: 0.75rem;
      }
      input,
      select,
      textarea {
        background-color: #f5f5f5;
        width: 100%;
      }
      label:not(.wpforms-field-label) {
        display: grid;
        font-size: 1rem;
        gap: 0.5rem;
      }
      button[type="submit"],
      input[type="submit"] {
        background-color: var(--link-color);
        border-color: var(--link-color);
        color: white;
        cursor: pointer;
        padding-inline: 1rem;
        width: auto;
        &:hover {
          background-color: var(--secondary-color);
        }
      }
    }

    section {
      line-height: 1.5;
      font-size: 1.125rem;

      h1 {
        font-size: 2.5rem;
        font-weight: 300;
        line-height: 1.4;
        margin: 0 0 1.5rem;

        span {
          color: var(--secondary-color);
        }

        /* make the text touch the top of the element */
        &::before {
          content: "";
          display: block;
          height: 0;
          margin-top: -0.5rem;
          width: 0;
        }
      }

      h2 a {
        font-weight: inherit;
      }

      iframe,
      img {
        max-width: 100%;
      }

      img {
        height: auto;
      }

      .edit-link {
        display: none;
      }

      .wp-block-button__link {
        background-color: var(--link-color);
        border-radius: 0.5rem;
        color: white;
        &:hover {
          background-color: var(--secondary-color);
        }
      }

      form.post-password-form {
        p:last-child {
          align-items: flex-end;
          display: flex;
          gap: 1rem;
        }
        label {
          width: 18rem;
        }
      }

      article + article {
        border-top: 1px solid var(--border-color);
        margin-top: 2rem;
      }
    }

    aside {
      line-height: 1.3;
      display: flex;
      flex-direction: column;
      gap: 2rem;

      form#cnca-search {
        position: relative;
        &:after {
          background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='%23666' class='size-6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z' /%3E%3C/svg%3E%0A");
          background-position: center;
          background-repeat: no-repeat;
          background-size: 1.25rem 1.25rem;
          content: "";
          display: block;
          position: absolute;
          left: 0;
          top: 50%;
          margin: -0.625rem 0 0 0.625rem;
          width: 1.25rem;
          height: 1.25rem;
        }
        input {
          padding-left: 2rem;
        }
      }

      ul.menu {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin: 0;
        padding-left: 1rem;
      }

      .simcal-calendar {
        max-width: calc(100vw - 2rem);
        padding: 0;
        > .simcal-align-right,
        .simcal-event-description + br {
          display: none;
        }
        dt {
          margin-bottom: 0;
        }
        ul.simcal-events {
          margin: 0;
          padding: 0;
          li.simcal-event {
            cursor: pointer;
            margin: 0;
            padding: 1rem 0.5rem;

            p {
              font-size: 0.875rem;
              margin: 0;
            }

            .details {
              max-height: 0;
              opacity: 0;
              overflow: hidden;
              border-left: 0.5rem solid #eee;
              padding-left: 1rem;
              margin-top: 0.5rem;
            }

            & + li {
              border-top: 1px solid #ddd;
            }

            &:not(.active):hover {
              background-color: #f5f5f5;
            }
          }
        }
      }
    }
  }

  > footer {
    background-color: var(--background-color);
    font-size: 0.875rem;
    padding: 2.5rem 1.25rem;
    text-align: center;

    ul.menu {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      list-style-type: none;
      margin: 0;
      padding: 0;
      ul {
        display: none;
      }
      li {
        padding: 1rem;
      }
    }
  }

  @media screen and (min-width: 768px) {
    > nav {
      padding: 0;

      a {
        text-transform: uppercase;
      }

      label {
        display: none;
      }

      > ul {
        display: flex;
        flex-direction: row;
        justify-content: center;

        ul {
          display: none;
        }

        ul a {
          font-size: 0.875rem;
          padding: 1rem;
          text-align: left;
        }

        > li:hover > ul {
          background-color: var(--primary-color);
          border-radius: 0 0 0.75rem 0.75rem;
          box-shadow: 0.5rem 0.5rem 0 0 #cccccc66;
          display: block;
          overflow: hidden;
          position: absolute;

          > li:last-child > a {
            padding-bottom: 18px;
          }
        }
      }
    }

    > header {
      padding: 1rem 0;
      a img {
        width: 12rem;
      }
    }

    > main {
      grid-template-columns: 1fr 300px;
      padding-inline: 3rem;
    }
  }
}
