/* app/assets/stylesheets/calendar.css
 *
 * Extracted from an inline <style> block in app/views/calendar/index.html.erb
 * so it's a real, cacheable, pipeline-processed asset instead of being
 * re-downloaded as part of every page response. Also switched off the
 * Google Fonts @import (render-blocking third-party request) in favor of
 * system font stacks, so the tool has no external dependency and works
 * offline. If you'd rather keep the exact Spectral/Inter/IBM Plex Mono
 * look, self-hosting those three font files under app/assets/fonts and
 * adding @font-face rules here is the alternative — just something I
 * couldn't do myself without network access to fetch the font binaries.
 */

.monajjem {
      --bg:        #12162A;
      --surface:   #1B2140;
      --surface-2: #212849;
      --ink:       #E8E3D3;
      --ink-dim:   #9096B0;
      --brass:     #C9A24B;
      --brass-dim: #8A7538;
      --rust:      #B1543A;
      --hairline:  rgba(232, 227, 211, 0.12);

      --font-display: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', serif;
      --font-ui:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
      --font-data:    ui-monospace, 'SF Mono', 'Cascadia Code', 'Roboto Mono', Menlo, Consolas, monospace;

      background: var(--bg);
      color: var(--ink);
      font-family: var(--font-ui);
      padding: 3rem 1.25rem 4rem;
      min-height: 100vh;
      box-sizing: border-box;
    }

    .monajjem *, .monajjem *::before, .monajjem *::after {
      box-sizing: border-box;
    }

    .monajjem__card {
      max-width: 620px;
      margin: 0 auto;
      background: var(--surface);
      border: 1px solid var(--hairline);
      border-radius: 18px;
      padding: 2.5rem 2rem 2rem;
      box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
    }

    .monajjem__title {
      font-family: var(--font-display);
      font-weight: 600;
      font-size: 2.1rem;
      letter-spacing: 0.14em;
      text-align: center;
      margin: 0;
      color: var(--ink);
    }

    .monajjem__byline {
      text-align: center;
      font-size: 0.8rem;
      color: var(--ink-dim);
      margin: 0.35rem 0 0;
      letter-spacing: 0.02em;
    }

    .monajjem__instruction {
      text-align: center;
      font-size: 0.85rem;
      color: var(--ink-dim);
      font-style: italic;
      margin: 0.6rem 0 2rem;
    }

    /* ---- Error banner: replaces alert() dialogs. Persistent — stays
       visible until the user dismisses it or tries another action, never
       auto-fades, since messages like "The Day is not a number" are
       things the user needs to actually read and act on. ---- */
    .monajjem__alert {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 0.75rem;
      background: rgba(177, 84, 58, 0.16);
      border: 1px solid var(--rust);
      color: var(--ink);
      border-radius: 8px;
      padding: 0.65rem 0.8rem;
      font-family: var(--font-ui);
      font-size: 0.85rem;
      line-height: 1.4;
      margin: 0 0 1.5rem;
    }

    .monajjem__alert[hidden] {
      display: none;
    }

    .monajjem__alert-dismiss {
      flex: 0 0 auto;
      background: none;
      border: none;
      color: var(--ink-dim);
      font-size: 1.1rem;
      line-height: 1;
      padding: 0 0.1rem;
      cursor: pointer;
      transition: color 0.15s ease;
    }

    .monajjem__alert-dismiss:hover,
    .monajjem__alert-dismiss:focus-visible {
      color: var(--ink);
      outline: none;
    }

    /* ---- Day-of-week readout with a quiet astrolabe-ring signature ---- */
    .monajjem__dial {
      position: relative;
      width: 168px;
      height: 168px;
      margin: 0 auto 2.25rem;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .monajjem__dial svg {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      opacity: 0.55;
    }

    /* Spinner: an extra ring on the same dial, only visible while a
       request is in flight (toggled via .monajjem--loading on the root
       element in the controller). Reuses the astrolabe motif already
       established by the SVG rings rather than a generic spinner icon. */
    .monajjem__spinner {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 118px;
      height: 118px;
      transform: translate(-50%, -50%);
      border-radius: 50%;
      border: 2px solid transparent;
      border-top-color: var(--brass);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.15s ease;
    }

    .monajjem--loading .monajjem__spinner {
      opacity: 1;
      animation: monajjem-spin 0.9s linear infinite;
    }

    @keyframes monajjem-spin {
      to { transform: translate(-50%, -50%) rotate(360deg); }
    }

    .monajjem__dow {
      position: relative;
      width: 108px;
      height: 108px;
      border-radius: 50%;
      background: var(--surface-2);
      border: 1px solid var(--brass-dim);
      color: var(--brass);
      font-family: var(--font-data);
      font-size: 0.95rem;
      font-weight: 600;
      letter-spacing: 0.02em;
      text-align: center;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0.5rem;
    }

    /* ---- Calendar ledger rows ---- */
    .monajjem__rows {
      border-top: 1px solid var(--hairline);
    }

    .cal-row {
      display: grid;
      grid-template-columns: 3.2rem 9.5rem 4.2rem 8.5rem;
      column-gap: 0.6rem;
      align-items: center;
      justify-content: center;
      padding: 0.85rem 0;
      border-bottom: 1px solid var(--hairline);
    }

    .cal-row__label {
      font-family: var(--font-ui);
      font-weight: 600;
      font-size: 0.72rem;
      letter-spacing: 0.09em;
      text-transform: uppercase;
      color: var(--brass);
      background: var(--surface-2);
      border: 1px solid var(--hairline);
      border-radius: 6px;
      padding: 0.45rem 0.6rem;
      cursor: pointer;
      text-align: left;
      width: 100%;
      transition: color 0.15s ease, border-color 0.15s ease;
    }

    .cal-row__label:hover,
    .cal-row__label:focus-visible {
      color: var(--ink);
      border-color: var(--brass-dim);
    }

    /* Lets the day/month/year inputs flow directly into the parent grid's
       three columns instead of being sized as one wrapped-up unit. */
    .cal-row__fields {
      display: contents;
    }

    .field-day,
    .field-year {
      font-family: var(--font-data);
      font-size: 0.92rem;
      color: var(--ink);
      background: var(--surface-2);
      border: 1px solid var(--hairline);
      border-radius: 6px;
      padding: 0.4rem 0.5rem;
      text-align: right;
      width: 100%;
    }

    .field-month {
      font-family: var(--font-ui);
      font-size: 0.85rem;
      color: var(--ink);
      background: var(--surface-2);
      border: 1px solid var(--hairline);
      border-radius: 6px;
      padding: 0.4rem 0.5rem;
      width: 100%;
    }

    .field-day:focus-visible,
    .field-year:focus-visible,
    .field-month:focus-visible,
    .cal-row__label:focus-visible {
      outline: 2px solid var(--brass);
      outline-offset: 2px;
    }

    /* ---- Step controls ---- */
    .monajjem__steps {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      justify-content: center;
      margin: 1.75rem 0 0.5rem;
    }

    .btn {
      font-family: var(--font-ui);
      font-weight: 600;
      font-size: 0.78rem;
      letter-spacing: 0.03em;
      color: var(--bg);
      background: var(--brass);
      border: 1px solid var(--brass);
      border-radius: 8px;
      padding: 0.6rem 1.1rem;
      cursor: pointer;
      flex-shrink: 0;
      transition: background 0.15s ease, transform 0.05s ease;
    }

    .btn:hover { background: #DCB25E; }
    .btn:active { transform: translateY(1px); }
    .btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

    .btn--nav {
      min-width: 10rem;
    }

    /* ---- Settings ---- */
    .monajjem__settings {
      margin-top: 2.25rem;
      padding-top: 1.5rem;
      border-top: 1px solid var(--hairline);
      display: grid;
      gap: 1rem;
    }

    .setting {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      flex-wrap: wrap;
    }

    .setting__label {
      font-size: 0.78rem;
      color: var(--ink-dim);
      flex: 1 1 auto;
    }

    .setting select {
      font-family: var(--font-ui);
      font-size: 0.8rem;
      color: var(--ink);
      background: var(--surface-2);
      border: 1px solid var(--hairline);
      border-radius: 6px;
      padding: 0.4rem 0.55rem;
    }

    .monajjem__footer {
      text-align: center;
      font-size: 0.7rem;
      color: var(--ink-dim);
      margin-top: 2rem;
      letter-spacing: 0.03em;
    }

    @media (prefers-reduced-motion: reduce) {
      .monajjem *,
      .monajjem *::before,
      .monajjem *::after {
        transition: none !important;
      }

      .monajjem--loading .monajjem__spinner {
        animation: none;
        opacity: 0.7;
      }
    }

    @media (max-width: 480px) {
      .monajjem { padding: 2rem 0.75rem 3rem; }
      .monajjem__card { padding: 2rem 1.25rem 1.5rem; }
      .cal-row {
        grid-template-columns: 3.2rem 1fr 4.2rem;
        row-gap: 0.35rem;
      }
      .cal-row__label {
        grid-column: 1 / -1;
        text-align: left;
      }
    }
