/**
 * @fileoverview Calculator Component Styles
 * @description Styles for the calculator component following BEM methodology.
 * Implements Material Design 3 principles with fixed-width layout,
 * dynamic font scaling, and state layer overlays for interactive elements.
 *
 * @module calculator
 * @version 1.0.1
 */

/* ==========================================================================
   CALCULATOR COMPONENT (BEM)
   Block: .calculator
   ========================================================================== */

/**
 * Calculator container.
 * Uses CSS Grid with 4 fixed-width columns and 1rem gap between buttons.
 * Width is fit-content to prevent expansion beyond button layout.
 */
.calculator {
  display: grid;
  grid-template-columns: repeat(4, 3.5rem);
  gap: 1rem;
  width: fit-content;
}

/* ======================================================================
   Elements
   ====================================================================== */

/**
 * Calculator display container.
 * Shows the current expression and result. Fixed height prevents overflow.
 * Uses Material Design elevation for depth.
 */
.calculator__display {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  min-height: 6rem;
  max-height: 6rem;
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: var(--md-sys-color-surface-container);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.30), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
  border-radius: 1rem;
  overflow: hidden;
}

/**
 * Expression display (top line).
 * Shows the current operation being performed.
 * Single line with ellipsis for overflow.
 */
.calculator__expression {
  width: 100%;
  font: var(--md-text-body-medium);
  color: var(--md-sys-color-on-surface-variant);
  min-height: 1.25rem;
  max-height: 1.5rem;
  word-break: break-all;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/**
 * Result display (main number).
 * Shows the current input or calculation result.
 * Limited to 2 lines with line-clamp, font size scales dynamically.
 */
.calculator__result {
  width: 100%;
  font-size: 2.8rem;
  line-height: 1.2;
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
  word-break: break-all;
  text-align: right;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
}

/**
 * Calculator button base styles.
 * Uses secondary container colors and includes state layer overlay
 * for hover effects following Material Design 3 guidelines.
 */
.calculator__button {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  align-self: stretch;
  width: 3.5rem;
  height: 3.5rem;
  padding: 1rem;
  border-radius: 1rem;
  background: var(--md-sys-color-secondary-container);
  border: none;
  font: var(--md-text-title-medium);
  color: var(--md-sys-color-on-secondary-container);
  cursor: pointer;
  transition: transform 0.1s ease;
}

/**
 * State layer overlay for calculator buttons.
 * Provides hover effect using semi-transparent overlay instead of
 * changing background color directly.
 */
.calculator__button::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  transition: background 0.15s ease;
  pointer-events: none;
}

/**
 * Hover state for calculator buttons.
 * Applies 8% opacity overlay on secondary container color.
 */
.calculator__button:hover::before {
    background: var(--State-Layers-On-Secondary-Container-Opacity-08, rgba(74, 68, 89, 0.08));
}

/**
 * Active/pressed state for calculator buttons.
 * Slight scale down provides tactile feedback.
 */
.calculator__button:active {
    transform: scale(0.96);
}

/* ======================================================================
   Modifiers
   ====================================================================== */

/**
 * Wide button modifier.
 * Spans 2 columns in the grid (used for the zero button).
 * Width calculated to include gap between columns.
 */
.calculator__button--wide {
  grid-column: span 2;
  width: calc(3.5rem * 2 + 1rem);
}
